jupyter_server: preferred_dir bug

Description

I’m not sure if this repo is the root cause of this bug, but setting --ServerApp.preferred_dir on the CLI overrides root_dir as well.

Example:

Reproduce

Example (assume cwd /path/to/cwd)

python3 -m venv myvenv --system-site-package
source myvenv/bin/activate
pip install jupyterlab
pip install git+https://github.com/jupyter-server/jupyter_server.git@1.x # clearer error messages

jupyter-lab --ServerApp.preferred_dir=/path/to/preferred

This errors (correctly) because /path/to/preferred is not a subdir of /path/to/cwd.

Now edit a config, such as ~/.jupyter/jupyter_server_config.py and put in:

c.ServerApp.root_dir = '/'
c.ServerApp.preferred_dir=`/path/to/preferred`

This works:

jupyter-lab

This does not as root-dir is overridden back to /path/to/cwd

jupyter-lab --ServerApp.preferred_dir=/path/to/preferred2

Expected behavior

Setting preferred_dir does not change root-dir.

Context

jupyter-server@1.x jupyterlab@3.3.4

About this issue

  • Original URL
  • State: closed
  • Created 2 years ago
  • Comments: 17 (12 by maintainers)

Most upvoted comments

Thx a lot @kevin-bates for the fix and associated tests. I have tested latest main and I confirm the issue is solved.

The backport PR to 1.x branch is available on https://github.com/jupyter-server/jupyter_server/pull/828