JupyterLab config issue in handling read-only config dir (user cannot save settings such as Dark Theme)

My understanding of JUPYTER_CONFIG_PATH (or JUPYTER_CONFIG_DIR) is that this env variable will prepend a directory to the default jupyter path, and jupyterlab will search through these directories and use the configuration settings populated in any of these directories. (Upon conflict, precedence is determined by the order, as returned by jupyter --path and the first one wins).

However, this is not what I have observed. It seems to have something to do with a directory in jupyyter lab with mode being set to read-only. Light/Dark theme is used as an example. Other user Settings are similarly affected too. (I am running on jupyterlab 3.1.0a5, Mac and Linux, and use Mac output below).

Here are the details:
A. First I use default settings.
a. Confirm no env variable (no JUPYTER_NO_CONFIG, JUPYTER_CONFIG_PATH or JUPYTER_CONFIG_DIR).
b. Ran on a fresh conda env with only jupyterlab=3.0.14
c. Confirm that I can change the Settings of theme from Light to Dark.
d. Filed saved was I can see the file in ~/.jupyter/lab/user-settings/@jupyterlab/apputils-extension/themes.jupyterlab-settings.
e. Upon restart of jupyterlab, it goes to Dark Theme correctly.
f. The output from juputer --path is: ~/.jupyter …

B. Then I set up JUPYTER_CONFIG_PATH:
a.

$ mkdir ~/tmp/.jupyter
$ chmod -w ~/tmp/.jupyter
$ export JUPYTER_CONFIG_PATH=~/tmp/.jupyter
$ jupyter --path
~/tmp/.jupyter
~/.jupyter


No settings in ~/tmp/.jupyter whereas there is correct setting file in ~/.jupyter.

b. I then start $ jupyter lab
Jupyterlab goes to default Light theme, despite my settings in ~/.jupyter.
Question 1: is this a bug? Should JLab looks for additional settings beyond ~/tmp/.jupyter?

c. Then I try to update my

Settings ==> JupyterLab Theme ==> JupyterLab Dark

There is an error message indicating permission error:

PermissionError: [Errno 13] Permission denied: ‘/Users/xxxx/tmp/.jupyter/lab/user-settings/@jupyterlab/apputils-extension/themes.jupyterlab-settings’

Questions 2: shouldn’t jlab try to find from each of the path, and write to the first writable one?

C. If I use JUPYTER_CONFIG_DIR (instead of JUPYTER_CONFIG_PATH):
jupyter --path will show ~/tmp/.jupyter (and system jupyter dir) but no ~/.jupyter
Upon jupyter lab starting up, it fails to come up:

PermissionError: [Errno 13] Permission denied: '/Users/xxxx/tmp/.jupyter/custom

Question 3: I was expecting JUPYTER_CONFIG_DIR should also include ~/.jupyter…

D. Same result in using jupyterlab==3.1.0a5 (issue b, c, d above)

E. Let me add the reason why we need to configure JUPYTER_CONFIG_PATH to be read-only?
In jupytelab 3.1.0a5, we can now configure to disable the download of files. So we would like to set up admin config (user read-only) to disable download as the first config that a user will see.

1 Like

Hey @hikemtshasta

The environment variable roles can be displayed when running

jupyter --paths --debug

JUPYTER_CONFIG_DIR overrides the default path when JUPYTER_CONFIG_PATH is preprended to the config paths

Now about the settings, there are two kinds of configuration: at the server level and at the frontend level. Server settings are indeed to be found in any path of jupyter --paths. But the frontend settings like the theme are not. They must lie in one unique folder. It can be set using JUPYTERLAB_SETTINGS_DIR and default to use the first jupyter path.

Now about your need, the solution is to set the page_config.json (it behaves like a server settings) file to disable some parts of JupyterLab: Adding an option to disable file download on Jupyterlab · Issue #5274 · jupyterlab/jupyterlab · GitHub

References:

1 Like

@ fcollonval:

Thanks very much! Your info is very much appreciated, as I didn’t know that JUPYTER_CONFIG_PATH only affects the server. I have tried the front-end config JUPYERLAB_SETTINGS_DIR as you mentioned and it works like a charm. So between these two env variables, I think I got what it takes to implement the solution.

Thanks again!