I think this is the same issue as Jupyter Notebook runs in root dir, not where it is located - #5 by mattcat26 , but I’m not entirely sure.
I have what’s basically a z2jh setup, where individual users have their own persistent homedirs on NFS. Everything is running inside Kubernetes, with users having unique and persistent UIDs and GIDs; each user gets their own namespace and their own FQDN for their Lab instance (none of that’s particularly relevant to the problem, except to say: it looks to the user like they’re the only user account on a large shared Linux machine they don’t have root on).
Previously we’ve been running with --notebook-dir set to $HOME. But because we want to start playing around with realtime collaboration (in a shared filesystem that uses POSIX groups to control access permissions) using jupyter-server-documents I now think that I want to start jupyter-singleuser with --FileContentsManager.root-dir=/ and --FileContentsManager.preferred-dir=$HOME.
That works, in that you can ascend all the way to the container root in the file browser, and the initial directory displayed is $HOME. And the terminal still opens in whatever directory you have open in the file browser.
What doesn’t work is that when I run any notebook, os.getcwd() comes back as $HOME rather than the directory containing the notebook. Since our users very very much tend to use relative paths, this breaks pretty much everything.
Have I misunderstood which settings to use? The behavior I want is what you get when you don’t set --FileContentsManager.preferred-dir where os.getcwd() from inside a notebook is the parent directory of that notebook.