jupyterhub / nbgitpuller

Jupyter server extension to sync a git repository one-way to a local path
https://nbgitpuller.readthedocs.io
BSD 3-Clause "New" or "Revised" License
205 stars 84 forks source link

Permission Denied: `--NotebookApp.notebook_dir` vs `--FileContentsManager.root_dir` #268

Open jbaksta opened 2 years ago

jbaksta commented 2 years ago

Bug description

--NotebookApp.notebook_dir vs --FileContentsManager.root_dir getting permission denied.

Expected behaviour

The git operation should occur in --NotebookApp.notebook_dir

Actual behaviour

The git operation is happening in --FileContentsManager.root_dir is passed to starting the JupyterLab instance. Based on PR #71 and associated issues I found relating to that it seems that it was desired to have the starting directory be the --NotebookApp.notebook_dir, but in my environment, I have notebook_dir set as $HOME, but --FileContentsManager.root_dir=/glade set because that's common root for our shared filesystems, but for demonstrations root_dir could be set to /home

How to reproduce

A minimum jupyterhub installation inside a VM that has the following configuration arguments and the user home directory being /home/$USER:

c.Spawner.args.append('--FileContentsManager.root_dir="/home"')
c.Spawner.args.append('--NotebookApp.notebook_dir="~"')

Your personal set up

python --version

Python 3.9.12

- <details><summary>Full environment</summary>
<!-- For reproduction, it's useful to have the full environment. For example, the output of `pip freeze` or `conda list` --->

packages in environment at /ncar/usr/jupyterhub.hpc.ucar.edu/test:

#

Name Version Build Channel

_libgcc_mutex 0.1 conda_forge conda-forge _openmp_mutex 4.5 1_gnu conda-forge aiofiles 0.7.0 pypi_0 pypi aiohttp 3.8.1 py39h3811e60_0 conda-forge aiosignal 1.2.0 pyhd8ed1ab_0 conda-forge alembic 1.7.7 pyhd8ed1ab_0 conda-forge aniso8601 7.0.0 pypi_0 pypi ansimarkup 1.5.0 pypi_0 pypi anyio 3.5.0 py39hf3d152e_0 conda-forge argon2-cffi 21.3.0 pyhd8ed1ab_0 conda-forge argon2-cffi-bindings 21.2.0 py39h7f8727e_0 asttokens 2.0.5 pyhd3eb1b0_0 async-timeout 4.0.2 pyhd8ed1ab_0 conda-forge async_generator 1.10 py_0 conda-forge asyncssh 2.10.0 pypi_0 pypi attrs 21.4.0 pyhd8ed1ab_0 conda-forge babel 2.9.1 pyh44b312d_0 conda-forge backcall 0.2.0 pyh9f0ad1d_0 conda-forge backports 1.0 py_2 conda-forge backports.functools_lru_cache 1.6.4 pyhd8ed1ab_0 conda-forge batchspawner 1.1.1.dev0 pypi_0 pypi beautifulsoup4 4.10.0 pyh06a4308_0 bleach 4.1.0 pyhd8ed1ab_0 conda-forge blinker 1.4 py_1 conda-forge bokeh 2.4.2 py39hf3d152e_0 conda-forge brotli 1.0.9 he6710b0_2 brotlipy 0.7.0 py39h3811e60_1003 conda-forge bzip2 1.0.8 h7b6447c_0 c-ares 1.18.1 h7f98852_0 conda-forge ca-certificates 2022.3.18 h06a4308_0 certifi 2021.10.8 py39h06a4308_2 certipy 0.1.3 py_0 conda-forge cffi 1.15.0 py39h4bc2ebd_0 conda-forge cfgv 3.3.1 pyhd8ed1ab_0 conda-forge chardet 4.0.0 py39hf3d152e_2 conda-forge charset-normalizer 2.0.4 pyhd3eb1b0_0 click 8.1.0 py39hf3d152e_0 conda-forge cloudpickle 2.0.0 pyhd8ed1ab_0 conda-forge colorama 0.4.4 pyh9f0ad1d_0 conda-forge commonmark 0.9.1 py_0 conda-forge conda 4.12.0 py39h06a4308_0 conda-package-handling 1.8.0 py39hb9d737c_0 conda-forge configurable-http-proxy 4.5.1 node17_h7e777a6_1 conda-forge coverage 6.3.2 py39hb9d737c_1 conda-forge cryptography 36.0.2 py39hd97740a_0 conda-forge curl 7.82.0 h7bff187_0 conda-forge cycler 0.11.0 pyhd3eb1b0_0 cylc-ext 0.1.1 pypi_0 pypi cylc-flow 8.0rc2 pypi_0 pypi cylc-uiserver 1.0.1 pypi_0 pypi cytoolz 0.11.2 py39h3811e60_1 conda-forge dask 2022.3.0 pyhd8ed1ab_0 conda-forge dask-core 2022.3.0 pyhd8ed1ab_0 conda-forge dask-labextension 5.2.0 pyhd8ed1ab_0 conda-forge dask_labextension 5.2.0 hd8ed1ab_0 conda-forge dataclasses 0.8 pyh6d0b6a4_7 debugpy 1.5.1 py39h295c915_0 decorator 5.1.1 pyhd8ed1ab_0 conda-forge defusedxml 0.7.1 pyhd8ed1ab_0 conda-forge deprecation 2.1.0 pyh9f0ad1d_0 conda-forge distlib 0.3.4 pyhd8ed1ab_0 conda-forge distributed 2022.3.0 pyhd8ed1ab_0 conda-forge elastic-transport 8.1.0 pypi_0 pypi elasticsearch 8.1.1 pypi_0 pypi entrypoints 0.4 pyhd8ed1ab_0 conda-forge executing 0.8.3 pyhd3eb1b0_0 filelock 3.6.0 pyhd8ed1ab_0 conda-forge flake8 4.0.1 pyhd8ed1ab_2 conda-forge flit-core 3.6.0 pyhd3eb1b0_0 fonttools 4.25.0 pyhd3eb1b0_0 freetype 2.10.4 h0708190_1 conda-forge frozenlist 1.2.0 py39h7f8727e_0 fsspec 2022.2.0 pyhd8ed1ab_0 conda-forge future 0.18.2 py39h06a4308_1 gettext 0.21.0 hf68c758_0 giflib 5.2.1 h7b6447c_0 gitdb 4.0.7 pyhd3eb1b0_0 gitpython 3.1.27 pyhd8ed1ab_0 conda-forge graphene 2.1.9 pypi_0 pypi graphene-tornado 2.6.1 pypi_0 pypi graphql-core 2.3.2 pypi_0 pypi graphql-relay 2.0.1 pypi_0 pypi graphql-ws 0.4.4 pypi_0 pypi greenlet 1.1.2 py39he80948d_1 conda-forge heapdict 1.0.1 py_0 conda-forge icu 69.1 h9c3ff4c_0 conda-forge identify 2.4.12 pyhd8ed1ab_0 conda-forge idna 3.3 pyhd8ed1ab_0 conda-forge importlib-metadata 4.11.3 py39hf3d152e_0 conda-forge importlib_resources 5.2.0 pyhd3eb1b0_1 invoke 1.7.0 pyhd8ed1ab_0 conda-forge ipykernel 6.10.0 py39hef51801_0 conda-forge ipython 8.2.0 py39hf3d152e_0 conda-forge ipython_genutils 0.2.0 py_1 conda-forge ipywidgets 7.7.0 pyhd8ed1ab_0 conda-forge jbig 2.1 h7f98852_2003 conda-forge jedi 0.18.1 py39hf3d152e_0 conda-forge jinja2 2.11.3 pypi_0 pypi jpeg 9e h7f98852_0 conda-forge json5 0.9.5 pyh9f0ad1d_0 conda-forge jsonschema 4.4.0 pyhd8ed1ab_0 conda-forge jupyter-packaging 0.12.0 pyhd8ed1ab_0 conda-forge jupyter-resource-usage 0.6.1 pyhd8ed1ab_0 conda-forge jupyter-server-mathjax 0.2.5 pyhc268e32_0 conda-forge jupyter-server-proxy 3.2.1 pyhd8ed1ab_0 conda-forge jupyter_client 7.2.0 pyhd8ed1ab_0 conda-forge jupyter_core 4.9.2 py39hf3d152e_0 conda-forge jupyter_server 1.15.6 pyhd8ed1ab_1 conda-forge jupyter_telemetry 0.1.0 pyhd8ed1ab_1 conda-forge jupyterhub 2.2.2 hd8ed1ab_0 conda-forge jupyterhub-base 2.2.2 pyhd8ed1ab_0 conda-forge jupyterlab 3.3.2 pyhd8ed1ab_0 conda-forge jupyterlab-git 0.36.0 pyhd8ed1ab_0 conda-forge jupyterlab-latex 3.1.0 pypi_0 pypi jupyterlab-mathjax3 4.3.0 pyhd8ed1ab_0 conda-forge jupyterlab-ncar-menu 0.1.1 pypi_0 pypi jupyterlab-nvdashboard 0.6.0 pyhd8ed1ab_0 conda-forge jupyterlab-recents 3.0.1 pyhd8ed1ab_0 conda-forge jupyterlab-server 2.10.3 pypi_0 pypi jupyterlab-sublime 0.4.1 pypi_0 pypi jupyterlab-variableinspector 3.0.9 pyhd8ed1ab_0 conda-forge jupyterlab_code_formatter 1.4.10 pyhd8ed1ab_1 conda-forge jupyterlab_pygments 0.1.2 pyh9f0ad1d_0 conda-forge jupyterlab_widgets 1.1.0 pyhd8ed1ab_0 conda-forge keyutils 1.6.1 h166bdaf_0 conda-forge kiwisolver 1.4.0 py39hf939315_0 conda-forge krb5 1.19.3 h3790be6_0 conda-forge lcms2 2.12 hddcbb42_0 conda-forge ld_impl_linux-64 2.36.1 hea4e1c9_2 conda-forge lerc 3.0 h9c3ff4c_0 conda-forge libarchive 3.5.2 hccf745f_1 conda-forge libblas 3.9.0 13_linux64_openblas conda-forge libcblas 3.9.0 13_linux64_openblas conda-forge libcurl 7.82.0 h7bff187_0 conda-forge libdeflate 1.10 h7f98852_0 conda-forge libedit 3.1.20191231 he28a2e2_2 conda-forge libev 4.33 h516909a_1 conda-forge libffi 3.4.2 h7f98852_5 conda-forge libgcc-ng 11.2.0 h1d223b6_14 conda-forge libgfortran-ng 11.2.0 h69a702a_14 conda-forge libgfortran5 11.2.0 h5c6108e_14 conda-forge libglib 2.70.2 h174f98d_4 conda-forge libgomp 11.2.0 h1d223b6_14 conda-forge libiconv 1.16 h516909a_0 conda-forge liblapack 3.9.0 13_linux64_openblas conda-forge libmamba 0.22.1 h9c208ef_0 conda-forge libmambapy 0.22.1 py39h3216e65_0 conda-forge libmemcached 1.0.18 h17b2bb4_1003 conda-forge libnghttp2 1.47.0 h727a467_0 conda-forge libnsl 2.0.0 h7f98852_0 conda-forge libopenblas 0.3.18 pthreads_h8fe5266_0 conda-forge libpng 1.6.37 h21135ba_2 conda-forge libsodium 1.0.18 h36c2ea0_1 conda-forge libsolv 0.7.20 h4ff587b_0 libssh2 1.10.0 ha56f1ee_2 conda-forge libstdcxx-ng 11.2.0 he4da1e4_14 conda-forge libtiff 4.3.0 h542a066_3 conda-forge libuuid 2.32.1 h7f98852_1000 conda-forge libuv 1.43.0 h7f98852_0 conda-forge libwebp 1.2.2 h55f646e_0 libwebp-base 1.2.2 h7f98852_1 conda-forge libxcb 1.13 h1bed415_1 libxml2 2.9.12 h885dcf4_1 conda-forge libzlib 1.2.11 h166bdaf_1014 conda-forge locket 0.2.0 py_2 conda-forge lz4-c 1.9.3 h9c3ff4c_1 conda-forge lzo 2.10 h7b6447c_2 mako 1.2.0 pyhd8ed1ab_0 conda-forge mamba 0.22.1 py39hfa8f2c8_0 conda-forge markdown 3.1.1 pypi_0 pypi markupsafe 2.0.1 pypi_0 pypi matplotlib-base 3.5.1 py39h2fa2bec_0 conda-forge matplotlib-inline 0.1.3 pyhd8ed1ab_0 conda-forge mccabe 0.6.1 py_1 conda-forge metomi-isodatetime 1!2.0.2 pypi_0 pypi mistune 0.8.4 py39h3811e60_1005 conda-forge mock 4.0.3 py39hf3d152e_2 conda-forge msgpack-python 1.0.3 py39h1a9c180_0 conda-forge multidict 6.0.2 py39h3811e60_0 conda-forge munkres 1.1.4 py_0 nb_conda_kernels 2.3.1 py39hf3d152e_1 conda-forge nbclassic 0.3.7 pyhd8ed1ab_0 conda-forge nbclient 0.5.13 pyhd8ed1ab_0 conda-forge nbconvert 5.6.1 pypi_0 pypi nbconvert-pandoc 6.4.5 pyhd8ed1ab_1 conda-forge nbdime 3.1.1 pyhd8ed1ab_0 conda-forge nbformat 5.2.0 pyhd8ed1ab_0 conda-forge nbgitpuller 1.1.0 pyhd8ed1ab_0 conda-forge nbviewer 1.0.1+265.gd9c5da7 pypi_0 pypi ncurses 6.3 h9c3ff4c_0 conda-forge nest-asyncio 1.5.4 pyhd8ed1ab_0 conda-forge newrelic 7.6.0.173 py39hb9d737c_0 conda-forge nodeenv 1.6.0 pyhd8ed1ab_0 conda-forge nodejs 17.8.0 h784f1fd_0 conda-forge nose 1.3.7 py_1006 conda-forge notebook 6.4.10 pyha770c72_0 conda-forge notebook-shim 0.1.0 pyhd8ed1ab_0 conda-forge numpy 1.22.3 py39h18676bf_0 conda-forge oauthlib 3.2.0 pyhd8ed1ab_0 conda-forge olefile 0.46 pyh9f0ad1d_1 conda-forge openjpeg 2.4.0 hb52868f_1 conda-forge openssl 1.1.1n h7f8727e_0 packaging 21.3 pyhd8ed1ab_0 conda-forge pamela 1.0.0 py_0 conda-forge pandas 1.4.1 py39hde0f152_0 conda-forge pandoc 2.17.1.1 ha770c72_0 conda-forge pandocfilters 1.5.0 pyhd8ed1ab_0 conda-forge panel 0.12.6 pyhd8ed1ab_0 conda-forge param 1.12.0 pyh6c4a22f_0 conda-forge parso 0.8.3 pyhd8ed1ab_0 conda-forge partd 1.2.0 pyhd8ed1ab_0 conda-forge pcre 8.45 h9c3ff4c_0 conda-forge pexpect 4.8.0 pyh9f0ad1d_2 conda-forge pickleshare 0.7.5 py_1003 conda-forge pillow 9.0.1 py39hae2aec6_2 conda-forge pip 22.0.4 pyhd8ed1ab_0 conda-forge platformdirs 2.5.1 pyhd8ed1ab_0 conda-forge pre-commit 2.17.0 py39hf3d152e_0 conda-forge prometheus_client 0.13.1 pyhd8ed1ab_0 conda-forge promise 2.3 pypi_0 pypi prompt-toolkit 3.0.27 pyha770c72_0 conda-forge protobuf 3.19.4 pypi_0 pypi psutil 5.9.0 py39h3811e60_0 conda-forge ptyprocess 0.7.0 pyhd3deb0d_0 conda-forge pure_eval 0.2.2 pyhd3eb1b0_0 pybind11-abi 4 hd8ed1ab_3 conda-forge pycodestyle 2.8.0 pyhd8ed1ab_0 conda-forge pycosat 0.6.3 py39h3811e60_1009 conda-forge pycparser 2.21 pyhd8ed1ab_0 conda-forge pyct 0.4.6 py_0 conda-forge pyct-core 0.4.6 pyhd3eb1b0_0 pycurl 7.45.1 py39hd73adbb_0 conda-forge pydantic 1.9.0 py39h3811e60_0 conda-forge pyflakes 2.4.0 pyhd8ed1ab_0 conda-forge pygments 2.11.2 pyhd8ed1ab_0 conda-forge pyjwt 2.3.0 pyhd8ed1ab_1 conda-forge pylibmc 1.6.1 py39h3811e60_4 conda-forge pynvml 11.4.1 pyhd8ed1ab_0 conda-forge pyopenssl 22.0.0 pyhd8ed1ab_0 conda-forge pyparsing 3.0.7 pyhd8ed1ab_0 conda-forge pyrsistent 0.18.1 py39h3811e60_0 conda-forge pysocks 1.7.1 py39hf3d152e_4 conda-forge python 3.9.12 h9a8a25e_1_cpython conda-forge python-dateutil 2.8.2 pyhd8ed1ab_0 conda-forge python-editor 1.0.4 py_0 conda-forge python-json-logger 2.0.1 pyh9f0ad1d_0 conda-forge python_abi 3.9 2_cp39 conda-forge pytz 2022.1 pyhd8ed1ab_0 conda-forge pyuv 1.4.0 pypi_0 pypi pyviz_comms 2.1.0 pyhd8ed1ab_0 conda-forge pyyaml 6.0 py39h3811e60_3 conda-forge pyzmq 22.3.0 py39h37b5a0c_1 conda-forge readline 8.1 h46c0cb4_0 conda-forge reproc 14.2.4 h295c915_1 reproc-cpp 14.2.4 h295c915_1 requests 2.27.1 pyhd8ed1ab_0 conda-forge rich 12.0.1 pyhd8ed1ab_0 conda-forge ruamel.yaml 0.17.21 py39h3811e60_0 conda-forge ruamel.yaml.clib 0.2.6 py39h3811e60_0 conda-forge ruamel_yaml 0.15.80 py39h3811e60_1006 conda-forge rx 1.6.1 pypi_0 pypi send2trash 1.8.0 pyhd8ed1ab_0 conda-forge setuptools 61.2.0 py39hf3d152e_1 conda-forge simpervisor 0.4 pyhd8ed1ab_0 conda-forge six 1.16.0 pyh6c4a22f_0 conda-forge smmap 5.0.0 pyhd8ed1ab_0 conda-forge sniffio 1.2.0 py39hf3d152e_2 conda-forge sortedcontainers 2.4.0 pyhd8ed1ab_0 conda-forge soupsieve 2.3.1 pyhd3eb1b0_0 sqlalchemy 1.4.32 py39hb9d737c_0 conda-forge sqlite 3.37.1 h4ff8645_0 conda-forge sshspawner 0.1.0 pypi_0 pypi stack_data 0.2.0 pyhd3eb1b0_0 statsd 3.3.0 py_0 conda-forge tblib 1.7.0 pyhd8ed1ab_0 conda-forge terminado 0.13.3 py39hf3d152e_0 conda-forge testpath 0.6.0 pyhd8ed1ab_0 conda-forge tk 8.6.12 h27826a3_0 conda-forge toml 0.10.2 pyhd8ed1ab_0 conda-forge tomli 1.2.2 pyhd3eb1b0_0 tomlkit 0.10.1 pyha770c72_0 conda-forge toolz 0.11.2 pyhd8ed1ab_0 conda-forge tornado 6.1 py39h3811e60_2 conda-forge tqdm 4.63.1 pyhd8ed1ab_0 conda-forge traitlets 5.1.1 pyhd8ed1ab_0 conda-forge typing 3.10.0.0 py39h06a4308_0 typing-extensions 4.1.1 hd8ed1ab_0 conda-forge typing_extensions 4.1.1 pyha770c72_0 conda-forge tzdata 2022a h191b570_0 conda-forge ukkonen 1.0.1 py39h1a9c180_1 conda-forge urllib3 1.26.9 pyhd8ed1ab_0 conda-forge urwid 2.1.2 pypi_0 pypi virtualenv 20.14.0 py39hf3d152e_0 conda-forge wcwidth 0.2.5 pyh9f0ad1d_2 conda-forge webencodings 0.5.1 py_1 conda-forge websocket-client 1.3.2 pyhd8ed1ab_0 conda-forge werkzeug 0.12.2 pypi_0 pypi wheel 0.37.1 pyhd8ed1ab_0 conda-forge widgetsnbextension 3.6.0 py39hf3d152e_0 conda-forge wrapspawner 1.0.1 pypi_0 pypi xz 5.2.5 h516909a_1 conda-forge yaml 0.2.5 h7f98852_2 conda-forge yaml-cpp 0.6.3 he1b5a44_4 conda-forge yarl 1.7.2 py39h3811e60_1 conda-forge zeromq 4.3.4 h9c3ff4c_1 conda-forge zict 2.1.0 pyhd8ed1ab_0 conda-forge zipp 3.7.0 pyhd8ed1ab_1 conda-forge zlib 1.2.11 h166bdaf_1014 conda-forge zstd 1.5.2 ha95c52a_0 conda-forge

</details>

- <details><summary>Configuration</summary>
A basic configuration with the two lines mentioned above:
```python
c.Spawner.args.append('--FileContentsManager.root_dir="/home"')
c.Spawner.args.append('--NotebookApp.notebook_dir="~"')

$ git clone --depth 1 --branch CSG_tutorial -- https://github.com/dphow/GPU_workshop /home/GPU_workshop
fatal: could not create work tree dir '/home/GPU_workshop': Permission denied

welcome[bot] commented 2 years ago

Thank you for opening your first issue in this project! Engagement like this is essential for open source projects! :hugs:
If you haven't done so already, check out Jupyter's Code of Conduct. Also, please try to follow the issue template as it helps other other community members to contribute more effectively. welcome You can meet the other Jovyans by joining our Discourse forum. There is also an intro thread there where you can stop by and say Hi! :wave:
Welcome to the Jupyter community! :tada:

jbaksta commented 2 years ago

As a workaround, I attempted to set the environment variable NBGITPULLER_PARENTPATH to relative directory to that of --FileContentsManager.root_dir and that provides me a good ability to do the clone minus the documented way things are expected to work. However, after the git clone operation completes successfully, the redirect attempts to access the repo at the --fileContentsManager.root_dir again and thus shows me a 404 in the tree view.