# JUPYTERLAB\_SETTINGS\_DIR defaults to JupyterHub root directory

**URL:** https://discourse.jupyter.org/t/jupyterlab-settings-dir-defaults-to-jupyterhub-root-directory/17103
**Category:** JupyterHub
**Created:** [December 5, 2022, 2:34pm UTC](https://discourse.jupyter.org/t/jupyterlab-settings-dir-defaults-to-jupyterhub-root-directory/17103 "2022-12-05T14:34:02Z")
**Posts on this page:** 7
**Page:** 1

<div class="post-metadata">

### Author: ![tisbam](https://yyz1.discourse-cdn.com/flex031/user_avatar/discourse.jupyter.org/tisbam/32/8636_2.png) [@tisbam](https://discourse.jupyter.org/u/tisbam)
#### Post date: [December 5, 2022, 2:34pm UTC](https://discourse.jupyter.org/t/jupyterlab-settings-dir-defaults-to-jupyterhub-root-directory/17103/1 "2022-12-05T14:34:02Z")

</div>

Hi,

I have setup Jupyterhub on a dedicated server :

- venv in /opt/jupyterhub
- Gitlab / Local authenticator with home directories automatically created
- Traefik proxy
- Default to /lab

Is it the standard that the started jupyter server for each user looks for the config in my /opt/jupyterhub/etc ?

To allow user to modify settings on their server I had to do the following “hack” :

```python
c.Spawner.environment = {'JUPYTERLAB_SETTINGS_DIR': lambda spawner: '/home/' + spawner.user.name + '/.jupyter'}

```

Else I had errors similar to this

```shell
Dec 05 14:23:14 jupyterhub jupyterhub[40373]: [W 2022-12-05 14:23:14.332 SingleUserLabApp web:1796] 500 PUT /user/XXX/lab/api/workspaces/default?1670250194370 (10.8.2.1): [Errno 13] Permission denied: '/opt/jupyterhub/etc/jupyter/lab'
Dec 05 14:23:14 jupyterhub jupyterhub[40373]: [W 2022-12-05 14:23:14.332 LabApp] wrote error: "[Errno 13] Permission denied: '/opt/jupyterhub/etc/jupyter/lab'"

```

I feel like this is a bit hackish for what I would consider pretty normal usage and I figure I probably have something misconfigured…

Thanks all

---

<div class="post-metadata">

### Author: ![bcornec](https://yyz1.discourse-cdn.com/flex031/user_avatar/discourse.jupyter.org/bcornec/32/8649_2.png) [@bcornec](https://discourse.jupyter.org/u/bcornec)
#### Post date: [December 6, 2022, 10:49am UTC](https://discourse.jupyter.org/t/jupyterlab-settings-dir-defaults-to-jupyterhub-root-directory/17103/2 "2022-12-06T10:49:42Z")

</div>

Having the same issue, I tried your hack without any luck. The env variable is correctly setup however we still have the permission denied in the logs.

This used to work flawlessly with:  
jupyterhub 2.3.1  
jupyter\_client : 7.3.5  
jupyter\_core : 4.11.1  
jupyter\_server : 1.18.1  
jupyterlab : 3.4.6

now we have:  
jupyterhub 3.0.0  
jupyter\_client : 7.4.7  
jupyter\_core : 5.0.0  
jupyter\_server : 1.23.3  
jupyterlab : 3.5.0

Even when changing default paths to have local paths first doesn’t seem to be read by jupyterhub (setting JUPYTER\_PREFER\_ENV\_PATH to 0 through systemd)

Of course we don’t want to open widely the ```  
/opt/jupyterhub/etc/jupyter

```nohighlight

Any hint to try or debug info to provide would be welcome.
TIA,
Bruno.
```

---

<div class="post-metadata">

### Author: ![tisbam](https://yyz1.discourse-cdn.com/flex031/user_avatar/discourse.jupyter.org/tisbam/32/8636_2.png) [@tisbam](https://discourse.jupyter.org/u/tisbam)
#### Post date: [December 6, 2022, 1:38pm UTC](https://discourse.jupyter.org/t/jupyterlab-settings-dir-defaults-to-jupyterhub-root-directory/17103/3 "2022-12-06T13:38:50Z")

</div>

Hi,

Is it weird the env variable is not taken into account.  
To be clear in my case, it still checks the /opt:jupyterhub/etc path before checking the one in homedir. So I still get the permission error, but in the end it finds a path with write access.

---

<div class="post-metadata">

### Author: ![bcornec](https://yyz1.discourse-cdn.com/flex031/user_avatar/discourse.jupyter.org/bcornec/32/8649_2.png) [@bcornec](https://discourse.jupyter.org/u/bcornec)
#### Post date: [December 6, 2022, 4:39pm UTC](https://discourse.jupyter.org/t/jupyterlab-settings-dir-defaults-to-jupyterhub-root-directory/17103/4 "2022-12-06T16:39:41Z")

</div>

Here are extracts from our log:

```auto
python3[186449]: [I 2022-12-06 10:24:10.545 SingleUserLabApp log:186] 302 GET /user/student401/ -> /user/student401/lab? (@127.0.0.1) 1.13ms
python3[186270]: [I 2022-12-06 10:24:10.546 JupyterHub base:963] User student401 took 3.150 seconds to start
[...]
python3[186270]: [I 2022-12-06 10:24:10.552 JupyterHub users:749] Server student401 is ready
python3[186270]: [I 2022-12-06 10:24:10.553 JupyterHub log:186] 200 GET /hub/api/users/student401/server/progress (student401@82.66.171.3) 1879.29ms
python3[186270]: [I 2022-12-06 10:24:10.614 JupyterHub log:186] 302 GET /hub/spawn-pending/student401 -> /user/student401/ (student401@82.66.171.3) 4.85ms
python3[186449]: [W 2022-12-06 10:24:10.624 SingleUserLabApp log:186] 403 GET /user/student401/terminals/websocket/1 (@82.66.171.3) 34.09ms
python3[186449]: [I 2022-12-06 10:24:10.658 SingleUserLabApp log:186] 302 GET /user/student401/ -> /user/student401/lab? (@82.66.171.3) 1.00ms
[...]
python3[186449]: [W 2022-12-06 10:24:15.167 LabApp] Could not determine jupyterlab build status without nodejs
python3[186449]: [I 2022-12-06 10:24:15.175 SingleUserLabApp log:186] 200 GET /user/student401/lab/api/build?1670322254347 (student401@82.66.171.3) 803.70ms
python3[186449]: [I 2022-12-06 10:24:15.183 SingleUserLabApp log:186] 200 GET /user/student401/lab/api/settings/@jupyterlab/application-extension:context-menu?1670322254880 (student401@82.66.171.3) 15.00ms
python3[186449]: [I 2022-12-06 10:24:15.227 SingleUserLabApp log:186] 200 GET /user/student401/lab/api/settings/@jupyterlab/shortcuts-extension:shortcuts?1670322255155 (student401@82.66.171.3) 18.82ms
python3[186449]: [W 2022-12-06 10:24:15.645 SingleUserLabApp web:1796] 500 PUT /user/student401/lab/api/workspaces/auto-0?1670322255615 (82.66.171.3): [Errno 13] Permission denied: '/opt/jupyterhub/etc/jupyter/lab/workspaces'
python3[186449]: [W 2022-12-06 10:24:15.646 LabApp] wrote error: "[Errno 13] Permission denied: '/opt/jupyterhub/etc/jupyter/lab/workspaces'"
python3[186449]: [E 2022-12-06 10:24:15.647 SingleUserLabApp log:178] {
python3[186449]: "X-Forwarded-Host": "notebooks3.hpedev.io",
python3[186449]: "X-Forwarded-Proto": "http",
python3[186449]: "X-Forwarded-Port": "80",
python3[186449]: "Referer": "http://notebooks3.hpedev.io/user/student401/lab/api/workspaces/auto-0",
python3[186449]: "X-Real-Ip": "82.66.171.3",
python3[186449]: "Host": "notebooks3.hpedev.io",
python3[186449]: "X-Forwarded-For": "82.66.171.3,::ffff:16.31.84.1",
python3[186449]: "Cache-Control": "no-cache",
python3[186449]: "Pragma": "no-cache",
python3[186449]: "Sec-Gpc": "1",
python3[186449]: "Dnt": "1",
python3[186449]: "Sec-Fetch-Site": "same-origin",
python3[186449]: "Sec-Fetch-Mode": "cors",
python3[186449]: "Sec-Fetch-Dest": "empty",
python3[186449]: "Cookie": "_xsrf=[secret]; jupyterhub-user-student401=[secret]; jupyterhub-session-id=[secret]",
python3[186449]: "Content-Length": "405",
python3[186449]: "Origin": "https://notebooks3.hpedev.io",
python3[186449]: "X-Xsrftoken": "2|b24c52ef|524c31b63e883ef8830e2be0be0aa2eb|1669226799",
python3[186449]: "Authorization": "token [secret]",
python3[186449]: "Content-Type": "text/plain;charset=UTF-8",
python3[186449]: "Accept-Encoding": "gzip, deflate, br",
python3[186449]: "Accept-Language": "en-US,fr;q=0.7,en;q=0.3",
python3[186449]: "Accept": "*/*",
python3[186449]: "User-Agent": "Mozilla/5.0 (X11; Linux x86_64; rv:102.0) Gecko/20100101 Firefox/102.0",
python3[186449]: "Connection": "close"
python3[186449]: }
python3[186449]: [E 2022-12-06 10:24:15.647 SingleUserLabApp log:186] 500 PUT /user/student401/lab/api/workspaces/auto-0?1670322255615 (student401@82.66.171.3) 4.02ms
python3[186449]: [I 2022-12-06 10:24:15.816 SingleUserLabApp log:186] 200 GET /user/student401/api/contents?content=1&1670322255736 (student401@82.66.171.3) 8.93ms
python3[186449]: [W 2022-12-06 10:24:16.303 SingleUserLabApp web:1796] 500 PUT /user/student401/lab/api/workspaces/auto-0?1670322256273 (82.66.171.3): [Errno 13] Permission denied: '/opt/jupyterhub/etc/jupyter/lab/workspaces'
python3[186449]: [W 2022-12-06 10:24:16.303 LabApp] wrote error: "[Errno 13] Permission denied: '/opt/jupyterhub/etc/jupyter/lab/workspaces'"
python3[186449]: [E 2022-12-06 10:24:16.305 SingleUserLabApp log:178] {
python3[186449]: "X-Forwarded-Host": "notebooks3.hpedev.io",
python3[186449]: "X-Forwarded-Proto": "http",
python3[186449]: "X-Forwarded-Port": "80",
python3[186449]: "Referer": "http://notebooks3.hpedev.io/user/student401/lab/api/workspaces/auto-0",
python3[186449]: "X-Real-Ip": "82.66.171.3",
python3[186449]: "Host": "notebooks3.hpedev.io",
python3[186449]: "X-Forwarded-For": "82.66.171.3,::ffff:16.31.84.1",
python3[186449]: "Cache-Control": "no-cache",
python3[186449]: "Pragma": "no-cache",
python3[186449]: "Sec-Gpc": "1",
python3[186449]: "Dnt": "1",
python3[186449]: "Sec-Fetch-Site": "same-origin",
python3[186449]: "Sec-Fetch-Mode": "cors",
python3[186449]: "Sec-Fetch-Dest": "empty",
python3[186449]: "Cookie": "_xsrf=[secret]; jupyterhub-user-student401=[secret]; jupyterhub-session-id=[secret]",
python3[186449]: "Content-Length": "450",
python3[186449]: "Origin": "https://notebooks3.hpedev.io",
python3[186449]: "X-Xsrftoken": "2|b24c52ef|524c31b63e883ef8830e2be0be0aa2eb|1669226799",
python3[186449]: "Authorization": "token [secret]",
python3[186449]: "Content-Type": "text/plain;charset=UTF-8",
python3[186449]: "Accept-Encoding": "gzip, deflate, br",
python3[186449]: "Accept-Language": "en-US,fr;q=0.7,en;q=0.3",
python3[186449]: "Accept": "*/*",
python3[186449]: "User-Agent": "Mozilla/5.0 (X11; Linux x86_64; rv:102.0) Gecko/20100101 Firefox/102.0",
python3[186449]: "Connection": "close"
python3[186449]: }
python3[186449]: [E 2022-12-06 10:24:16.305 SingleUserLabApp log:186] 500 PUT /user/student401/lab/api/workspaces/auto-0?1670322256273 (student401@82.66.171.3) 3.68ms
python3[186449]: [I 2022-12-06 10:24:17.059 SingleUserLabApp log:186] 200 GET /user/student401/api/nbconvert?1670322254579 (student401@82.66.171.3) 2324.50ms

```

And it seems indeed that the other conf files (we generate one under $HOME/.jupyter called jupyter\_notebook\_config.py containing:

```auto
c = get_config() # noqa
c.NotebookApp.default_url = 'WKSHP-API101/0-ReadMeFirst.ipynb'

```

doesn’t open automatically the notebook mentioned (this is what we ultimately try to achieve).  
(Path exists)

---

<div class="post-metadata">

### Author: ![iscilyas](https://yyz1.discourse-cdn.com/flex031/user_avatar/discourse.jupyter.org/iscilyas/32/8667_2.png) [@iscilyas](https://discourse.jupyter.org/u/iscilyas)
#### Post date: [December 8, 2022, 6:58am UTC](https://discourse.jupyter.org/t/jupyterlab-settings-dir-defaults-to-jupyterhub-root-directory/17103/5 "2022-12-08T06:58:56Z")

</div>

same here. for a while i’ve been noticing that my “settings” (such as theme choice) weren’t being applied but i was too busy to chase it down (and i thought i had misconfigured something). i find it odd that you’re the first to report this issue.

BTW, here’s what I ended up using (based on your hack):

```auto
c.Spawner.environment = {
        'JUPYTERLAB_SETTINGS_DIR': lambda spawner: '/home/' + spawner.user.name + '/.jupyter/lab/user-settings',
        'JUPYTERLAB_WORKSPACES_DIR': lambda spawner: '/home/' + spawner.user.name + '/.jupyter/lab/workspaces',
}

```

The above works fine.

---

<div class="post-metadata">

### Author: ![bcornec](https://yyz1.discourse-cdn.com/flex031/user_avatar/discourse.jupyter.org/bcornec/32/8649_2.png) [@bcornec](https://discourse.jupyter.org/u/bcornec)
#### Post date: [December 22, 2022, 1:34am UTC](https://discourse.jupyter.org/t/jupyterlab-settings-dir-defaults-to-jupyterhub-root-directory/17103/6 "2022-12-22T01:34:50Z")

</div>

Seems that our issue is now fixed with jupyterlab 3.5.2 !

---

<div class="post-metadata">

### Author: ![minrk](https://yyz1.discourse-cdn.com/flex031/user_avatar/discourse.jupyter.org/minrk/32/13_2.png) [@minrk](https://discourse.jupyter.org/u/minrk)
#### Post date: [December 22, 2022, 8:13am UTC](https://discourse.jupyter.org/t/jupyterlab-settings-dir-defaults-to-jupyterhub-root-directory/17103/7 "2022-12-22T08:13:40Z")

</div>

This was fixed by [this patch](https://github.com/jupyterlab/jupyterlab/pull/13589) (with lots of links to related discussion).

You can also set `JUPYTER_PREFER_ENV_PATH=0`:

```python
c.Spawner.environment.update({"JUPYTER_PREFER_ENV_PATH": "0"})

```

to avoid trying to store things in the env, if you need to wait to upgrade.
