jupyterhub / jupyterhub

Multi-user server for Jupyter notebooks
https://jupyterhub.readthedocs.io
Other
7.82k stars 2.02k forks source link

setting c.Spawner.disable_user_config = True prevents kernelspecs in $HOME from displaying #4940

Open kellyrowland opened 3 weeks ago

kellyrowland commented 3 weeks ago

Setting c.Spawner.disable_user_config = True in jupyterhub_config.py appears to be preventing kernels installed in $HOME (e.g., via python -m ipykernel install --user) from displaying.

I would not expect a "config" option to impact kernels, based on

Jupyter separates data files (nbextensions, kernelspecs) from runtime files (logs, pid files, connection files) from configuration (config files, custom.js).

stated at https://docs.jupyter.org/en/stable/use/jupyter-directories.html so maybe this is an unintended side effect of disabling the user config or maybe kernelspecs should be considered configuration.

minrk commented 2 weeks ago

Yeah, these things are not well separated. disable-user-config removes home directories from the prefixes Jupyter searches for everything, not just config. I'll need to do some digging on exactly where these things differentiate to allow it. I think the issue is that jupyter_path which resolves to 'data' directories is also where extensions reside (browser-side ones, at least), so it may still be correct to exclude them. I'll have to think about it some more. While I think kernel specs in particular from $HOME are considered safe, I'm less sure about data_dir generally.

I expected KernelSpecManager.kernel_dirs to have an override to be able to explicitly re-add a directory, but it's actually not configurable. There isn't a way to re-add a directory without getting your own Python code in there as a sysadmin, e.g. registering a ServerApp.kernel_spec_manager_class that customizes .kernel_dirs, or an ExtensionApp that accesses the serverapp.kernel_spec_manager.kernel_dirs list and appends to it. I will look into making that configurable, at least.