microsoft / vscode-jupyter-hub

Jupyter Hub Support in VS Code
https://marketplace.visualstudio.com/items?itemName=ms-toolsai.jupyter-hub
MIT License
8 stars 6 forks source link

Current working directory is `~/` regardless of notebook location #49

Closed basnijholt closed 1 day ago

basnijholt commented 4 months ago

Environment data

Dup of https://github.com/microsoft/vscode-jupyter-hub/issues/46 but @DonJayamanne asked for the fully filled in issue template here https://github.com/microsoft/vscode-jupyter-hub/issues/46#issuecomment-2004874516.

Expected behaviour

I open a notebook, e.g., at /home/bas.nijholt/adaptive-scheduler/example.ipynb and select a new kernel from JupyterHub.

I check import os; os.getcwd() and it shows /home/bas.nijholt instead of the folder in which the notebook lives (/home/bas.nijholt/adaptive-scheduler).

Actual behaviour

I expect that import os; os.getcwd() would return /home/bas.nijholt/adaptive-scheduler instead of my home folder.

See this:

image

Steps to reproduce:

[NOTE: Self-contained, minimal reproducing code samples are extremely helpful and will expedite addressing your issue]

  1. Open new notebook in a folder other than ~/
  2. Run import os; os.getcwd()
  3. Observe the incorrect cwd.

Logs

Output for Jupyter in the Output panel (ViewOutput, change the drop-down the upper-right of the Output panel to Jupyter)

``` Visual Studio Code (1.87.2, ssh-remote, desktop) Jupyter Extension Version: 2024.2.0. Python Extension Version: 2024.2.1. Pylance Extension Version: 2024.3.1. Platform: linux (x64). Multiple Workspace folders opened ~/proj, ~/adaptive-scheduler, ~/.adaptive-scheduler 00:35:44.655 [info] Telemetry level is off 00:35:44.655 [info] Experiments are disabled, only manually opted experiments are active. 00:35:44.655 [info] User belongs to experiment group 'KernelCompletions' 00:35:44.655 [info] User belongs to experiment group 'DoNotWaitForZmqPortsToBeUsed' 00:35:44.784 [info] Start refreshing Kernel Picker (1710808544784) 00:35:44.792 [info] Using Pylance 00:35:46.114 [info] Process Execution: ~/micromamba/envs/proj/bin/python -m pip list 00:35:47.124 [error] Failed to validate Password info D [FetchError]: request to http://localhost:34931/tree? failed, reason: connect ECONNREFUSED 127.0.0.1:34931 at ClientRequest. (~/.vscode-server/extensions/ms-toolsai.jupyter-2024.2.0-linux-x64/dist/node_modules/node-fetch.js:1:306417) at ClientRequest.emit (node:events:514:28) at Socket.socketErrorListener (node:_http_client:501:9) at Socket.emit (node:events:514:28) at emitErrorNT (node:internal/streams/destroy:151:8) at emitErrorCloseNT (node:internal/streams/destroy:116:3) at processTicksAndRejections (node:internal/process/task_queues:82:21) { type: 'system', errno: 'ECONNREFUSED', code: 'ECONNREFUSED' } 00:35:47.183 [error] Error fetching kernels from http://localhost:34931/ (localhost): FetchError: request to http://localhost:34931/api/kernels?1710808547148 failed, reason: connect ECONNREFUSED 127.0.0.1:34931 at ClientRequest. (~/.vscode-server/extensions/ms-toolsai.jupyter-2024.2.0-linux-x64/dist/node_modules/node-fetch.js:1:306417) at ClientRequest.emit (node:events:514:28) at Socket.socketErrorListener (node:_http_client:501:9) at Socket.emit (node:events:514:28) at emitErrorNT (node:internal/streams/destroy:151:8) at emitErrorCloseNT (node:internal/streams/destroy:116:3) at processTicksAndRejections (node:internal/process/task_queues:82:21) 00:35:47.185 [error] UniversalRemoteKernelFinder: Failed to get kernels without cache FetchError: request to http://localhost:34931/api/kernels?1710808547148 failed, reason: connect ECONNREFUSED 127.0.0.1:34931 at ClientRequest. (~/.vscode-server/extensions/ms-toolsai.jupyter-2024.2.0-linux-x64/dist/node_modules/node-fetch.js:1:306417) at ClientRequest.emit (node:events:514:28) at Socket.socketErrorListener (node:_http_client:501:9) at Socket.emit (node:events:514:28) at emitErrorNT (node:internal/streams/destroy:151:8) at emitErrorCloseNT (node:internal/streams/destroy:116:3) at processTicksAndRejections (node:internal/process/task_queues:82:21) 00:35:47.185 [error] Jupyter Lab Helper:getKernelSpecs failure: Error: Poll (@jupyterlab/services:KernelSpecManager#specs) is disposed. at v.dispose (~/.vscode-server/extensions/ms-toolsai.jupyter-2024.2.0-linux-x64/dist/node_modules/@jupyterlab/services.js:11:10935) at ni.dispose (~/.vscode-server/extensions/ms-toolsai.jupyter-2024.2.0-linux-x64/dist/node_modules/@jupyterlab/services.js:11:29299) at r.dispose (~/.vscode-server/extensions/ms-toolsai.jupyter-2024.2.0-linux-x64/dist/extension.node.js:198:12579) at processTicksAndRejections (node:internal/process/task_queues:95:5) at async Promise.all (index 0) at sD.listKernelsFromConnection (~/.vscode-server/extensions/ms-toolsai.jupyter-2024.2.0-linux-x64/dist/extension.node.js:308:20060) at ~/.vscode-server/extensions/ms-toolsai.jupyter-2024.2.0-linux-x64/dist/extension.node.js:308:17485 00:35:47.655 [info] Starting Kernel connectToLiveRemoteKernel, ce5ca65b-cf52-4e38-9d15-5e7b887212ba for '~/adaptive-scheduler/example.ipynb' (disableUI=true) 00:35:48.236 [info] Started session for kernel connectToLiveRemoteKernel:ce5ca65b-cf52-4e38-9d15-5e7b887212ba 00:35:48.244 [info] Registering Kernel Completion Provider from kernel Python 3 (ipykernel) (example.ipynb) for language python 00:35:48.529 [error] Failed to validate Password info D [FetchError]: request to http://localhost:34931/tree? failed, reason: connect ECONNREFUSED 127.0.0.1:34931 at ClientRequest. (~/.vscode-server/extensions/ms-toolsai.jupyter-2024.2.0-linux-x64/dist/node_modules/node-fetch.js:1:306417) at ClientRequest.emit (node:events:514:28) at Socket.socketErrorListener (node:_http_client:501:9) at Socket.emit (node:events:514:28) at emitErrorNT (node:internal/streams/destroy:151:8) at emitErrorCloseNT (node:internal/streams/destroy:116:3) at processTicksAndRejections (node:internal/process/task_queues:82:21) { type: 'system', errno: 'ECONNREFUSED', code: 'ECONNREFUSED' } 00:35:48.576 [error] Error fetching kernels from http://localhost:34931/ (localhost): FetchError: request to http://localhost:34931/api/kernels?1710808548531 failed, reason: connect ECONNREFUSED 127.0.0.1:34931 at ClientRequest. (~/.vscode-server/extensions/ms-toolsai.jupyter-2024.2.0-linux-x64/dist/node_modules/node-fetch.js:1:306417) at ClientRequest.emit (node:events:514:28) at Socket.socketErrorListener (node:_http_client:501:9) at Socket.emit (node:events:514:28) at emitErrorNT (node:internal/streams/destroy:151:8) at emitErrorCloseNT (node:internal/streams/destroy:116:3) at processTicksAndRejections (node:internal/process/task_queues:82:21) 00:35:48.577 [warn] Could not fetch kernels from the remote server, falling back to cache: TypeError: request to http://localhost:34931/api/kernels?1710808548531 failed, reason: connect ECONNREFUSED 127.0.0.1:34931 00:35:48.577 [error] Jupyter Lab Helper:getKernelSpecs failure: Error: Poll (@jupyterlab/services:KernelSpecManager#specs) is disposed. at v.dispose (~/.vscode-server/extensions/ms-toolsai.jupyter-2024.2.0-linux-x64/dist/node_modules/@jupyterlab/services.js:11:10935) at ni.dispose (~/.vscode-server/extensions/ms-toolsai.jupyter-2024.2.0-linux-x64/dist/node_modules/@jupyterlab/services.js:11:29299) at r.dispose (~/.vscode-server/extensions/ms-toolsai.jupyter-2024.2.0-linux-x64/dist/extension.node.js:198:12579) at processTicksAndRejections (node:internal/process/task_queues:95:5) at async Promise.all (index 0) at sD.listKernelsFromConnection (~/.vscode-server/extensions/ms-toolsai.jupyter-2024.2.0-linux-x64/dist/extension.node.js:308:20060) at ~/.vscode-server/extensions/ms-toolsai.jupyter-2024.2.0-linux-x64/dist/extension.node.js:308:17959 00:35:49.807 [info] End refreshing Kernel Picker (1710808544784) 00:35:56.778 [info] Disposing kernel ce5ca65b-cf52-4e38-9d15-5e7b887212ba for notebook ~/adaptive-scheduler/example.ipynb due to selection of another kernel or closing of the notebook 00:35:56.778 [info] Dispose Kernel '~/adaptive-scheduler/example.ipynb' associated with '~/adaptive-scheduler/example.ipynb' 00:35:58.781 [info] Start refreshing Kernel Picker (1710808558781) 00:35:58.794 [error] Failed to validate Password info D [FetchError]: request to http://localhost:34931/tree? failed, reason: connect ECONNREFUSED 127.0.0.1:34931 at ClientRequest. (~/.vscode-server/extensions/ms-toolsai.jupyter-2024.2.0-linux-x64/dist/node_modules/node-fetch.js:1:306417) at ClientRequest.emit (node:events:514:28) at Socket.socketErrorListener (node:_http_client:501:9) at Socket.emit (node:events:514:28) at emitErrorNT (node:internal/streams/destroy:151:8) at emitErrorCloseNT (node:internal/streams/destroy:116:3) at processTicksAndRejections (node:internal/process/task_queues:82:21) { type: 'system', errno: 'ECONNREFUSED', code: 'ECONNREFUSED' } 00:35:58.812 [error] Error fetching kernels from http://localhost:34931/ (localhost): FetchError: request to http://localhost:34931/api/kernels?1710808558795 failed, reason: connect ECONNREFUSED 127.0.0.1:34931 at ClientRequest. (~/.vscode-server/extensions/ms-toolsai.jupyter-2024.2.0-linux-x64/dist/node_modules/node-fetch.js:1:306417) at ClientRequest.emit (node:events:514:28) at Socket.socketErrorListener (node:_http_client:501:9) at Socket.emit (node:events:514:28) at emitErrorNT (node:internal/streams/destroy:151:8) at emitErrorCloseNT (node:internal/streams/destroy:116:3) at processTicksAndRejections (node:internal/process/task_queues:82:21) 00:35:58.813 [warn] Could not fetch kernels from the remote server, falling back to cache: TypeError: request to http://localhost:34931/api/kernels?1710808558795 failed, reason: connect ECONNREFUSED 127.0.0.1:34931 00:35:58.814 [error] Jupyter Lab Helper:getKernelSpecs failure: Error: Poll (@jupyterlab/services:KernelSpecManager#specs) is disposed. at v.dispose (~/.vscode-server/extensions/ms-toolsai.jupyter-2024.2.0-linux-x64/dist/node_modules/@jupyterlab/services.js:11:10935) at ni.dispose (~/.vscode-server/extensions/ms-toolsai.jupyter-2024.2.0-linux-x64/dist/node_modules/@jupyterlab/services.js:11:29299) at r.dispose (~/.vscode-server/extensions/ms-toolsai.jupyter-2024.2.0-linux-x64/dist/extension.node.js:198:12579) at processTicksAndRejections (node:internal/process/task_queues:95:5) at async Promise.all (index 0) at sD.listKernelsFromConnection (~/.vscode-server/extensions/ms-toolsai.jupyter-2024.2.0-linux-x64/dist/extension.node.js:308:20060) at ~/.vscode-server/extensions/ms-toolsai.jupyter-2024.2.0-linux-x64/dist/extension.node.js:308:17959 00:35:58.850 [info] End refreshing Kernel Picker (1710808558781) 00:36:00.052 [info] Handle Execution of Cells 0 for ~/adaptive-scheduler/example.ipynb 00:36:00.053 [info] Starting Kernel startUsingRemoteKernelSpec, 0f7cf654e8f4259721462c12497ccc916607080c840d3961d51940c03713d45e..python3./opt/micromamba/envs/jupyterhub/python./.-m#ipykernel_launcher for '~/adaptive-scheduler/example.ipynb' (disableUI=false) 00:36:00.096 [info] http://{REMOVED}:9000/user//: Kernel started: dd3a8adb-fa43-4f92-ab9e-db43e09b6889 00:36:00.422 [info] Started session for kernel startUsingRemoteKernelSpec:0f7cf654e8f4259721462c12497ccc916607080c840d3961d51940c03713d45e..python3./opt/micromamba/envs/jupyterhub/python./.-m#ipykernel_launcher 00:36:00.526 [info] Registering Kernel Completion Provider from kernel Python 3 (ipykernel) for language python 00:36:00.527 [info] Start refreshing Kernel Picker (1710808560527) 00:36:00.546 [info] Kernel acknowledged execution of cell 0 @ 1710808560546 00:36:00.553 [error] Failed to validate Password info D [FetchError]: request to http://localhost:34931/tree? failed, reason: connect ECONNREFUSED 127.0.0.1:34931 at ClientRequest. (~/.vscode-server/extensions/ms-toolsai.jupyter-2024.2.0-linux-x64/dist/node_modules/node-fetch.js:1:306417) at ClientRequest.emit (node:events:514:28) at Socket.socketErrorListener (node:_http_client:501:9) at Socket.emit (node:events:514:28) at emitErrorNT (node:internal/streams/destroy:151:8) at emitErrorCloseNT (node:internal/streams/destroy:116:3) at processTicksAndRejections (node:internal/process/task_queues:82:21) { type: 'system', errno: 'ECONNREFUSED', code: 'ECONNREFUSED' } 00:36:00.559 [info] End cell 0 execution after 0.013s, completed @ 1710808560559, started @ 1710808560546 00:36:00.566 [error] Error fetching kernels from http://localhost:34931/ (localhost): FetchError: request to http://localhost:34931/api/kernels?1710808560554 failed, reason: connect ECONNREFUSED 127.0.0.1:34931 at ClientRequest. (~/.vscode-server/extensions/ms-toolsai.jupyter-2024.2.0-linux-x64/dist/node_modules/node-fetch.js:1:306417) at ClientRequest.emit (node:events:514:28) at Socket.socketErrorListener (node:_http_client:501:9) at Socket.emit (node:events:514:28) at emitErrorNT (node:internal/streams/destroy:151:8) at emitErrorCloseNT (node:internal/streams/destroy:116:3) at processTicksAndRejections (node:internal/process/task_queues:82:21) 00:36:00.567 [warn] Could not fetch kernels from the remote server, falling back to cache: TypeError: request to http://localhost:34931/api/kernels?1710808560554 failed, reason: connect ECONNREFUSED 127.0.0.1:34931 00:36:00.567 [error] Jupyter Lab Helper:getKernelSpecs failure: Error: Poll (@jupyterlab/services:KernelSpecManager#specs) is disposed. at v.dispose (~/.vscode-server/extensions/ms-toolsai.jupyter-2024.2.0-linux-x64/dist/node_modules/@jupyterlab/services.js:11:10935) at ni.dispose (~/.vscode-server/extensions/ms-toolsai.jupyter-2024.2.0-linux-x64/dist/node_modules/@jupyterlab/services.js:11:29299) at r.dispose (~/.vscode-server/extensions/ms-toolsai.jupyter-2024.2.0-linux-x64/dist/extension.node.js:198:12579) at processTicksAndRejections (node:internal/process/task_queues:95:5) at async Promise.all (index 0) at sD.listKernelsFromConnection (~/.vscode-server/extensions/ms-toolsai.jupyter-2024.2.0-linux-x64/dist/extension.node.js:308:20060) at ~/.vscode-server/extensions/ms-toolsai.jupyter-2024.2.0-linux-x64/dist/extension.node.js:308:17959 00:36:00.605 [info] End refreshing Kernel Picker (1710808560527) ```

For completeness, the full env that runs our JupyterHub instance.

/opt/micromamba/bin/micromamba -p /opt/micromamba/envs/jupyterhub list
List of packages in environment: "/opt/micromamba/envs/jupyterhub"

  Name                           Version          Build               Channel    
───────────────────────────────────────────────────────────────────────────────────
  _libgcc_mutex                  0.1              conda_forge         conda-forge
  _openmp_mutex                  4.5              2_gnu               conda-forge
  alembic                        1.13.1           pyhd8ed1ab_1        conda-forge
  anyio                          4.3.0            pyhd8ed1ab_0        conda-forge
  argon2-cffi                    23.1.0           pyhd8ed1ab_0        conda-forge
  argon2-cffi-bindings           21.2.0           py311h459d7ec_4     conda-forge
  arrow                          1.3.0            pyhd8ed1ab_0        conda-forge
  asttokens                      2.4.1            pyhd8ed1ab_0        conda-forge
  async-lru                      2.0.4            pyhd8ed1ab_0        conda-forge
  async_generator                1.10             py_0                conda-forge
  attrs                          23.2.0           pyh71513ae_0        conda-forge
  babel                          2.14.0           pyhd8ed1ab_0        conda-forge
  beautifulsoup4                 4.12.3           pyha770c72_0        conda-forge
  bleach                         6.1.0            pyhd8ed1ab_0        conda-forge
  blinker                        1.7.0            pyhd8ed1ab_0        conda-forge
  brotli-python                  1.1.0            py311hb755f60_1     conda-forge
  bzip2                          1.0.8            hd590300_5          conda-forge
  c-ares                         1.27.0           hd590300_0          conda-forge
  ca-certificates                2024.2.2         hbcca054_0          conda-forge
  cached-property                1.5.2            hd8ed1ab_1          conda-forge
  cached_property                1.5.2            pyha770c72_1        conda-forge
  certifi                        2024.2.2         pyhd8ed1ab_0        conda-forge
  certipy                        0.1.3            py_0                conda-forge
  cffi                           1.16.0           py311hb3a22ac_0     conda-forge
  charset-normalizer             3.3.2            pyhd8ed1ab_0        conda-forge
  comm                           0.2.1            pyhd8ed1ab_0        conda-forge
  configurable-http-proxy        4.6.1            h92b4e83_0          conda-forge
  cryptography                   42.0.5           py311h63ff55d_0     conda-forge
  debugpy                        1.8.1            py311hb755f60_0     conda-forge
  decorator                      5.1.1            pyhd8ed1ab_0        conda-forge
  defusedxml                     0.7.1            pyhd8ed1ab_0        conda-forge
  entrypoints                    0.4              pyhd8ed1ab_0        conda-forge
  exceptiongroup                 1.2.0            pyhd8ed1ab_2        conda-forge
  executing                      2.0.1            pyhd8ed1ab_0        conda-forge
  fqdn                           1.5.1            pyhd8ed1ab_0        conda-forge
  greenlet                       3.0.3            py311hb755f60_0     conda-forge
  h11                            0.14.0           pyhd8ed1ab_0        conda-forge
  h2                             4.1.0            pyhd8ed1ab_0        conda-forge
  hpack                          4.0.0            pyh9f0ad1d_0        conda-forge
  httpcore                       1.0.4            pyhd8ed1ab_0        conda-forge
  httpx                          0.27.0           pyhd8ed1ab_0        conda-forge
  hyperframe                     6.0.1            pyhd8ed1ab_0        conda-forge
  icu                            73.2             h59595ed_0          conda-forge
  idna                           3.6              pyhd8ed1ab_0        conda-forge
  importlib-metadata             7.0.1            pyha770c72_0        conda-forge
  importlib_metadata             7.0.1            hd8ed1ab_0          conda-forge
  importlib_resources            6.1.2            pyhd8ed1ab_0        conda-forge
  ipykernel                      6.29.3           pyhd33586a_0        conda-forge
  ipython                        8.22.1           pyh707e725_0        conda-forge
  isoduration                    20.11.0          pyhd8ed1ab_0        conda-forge
  jedi                           0.19.1           pyhd8ed1ab_0        conda-forge
  jinja2                         3.1.3            pyhd8ed1ab_0        conda-forge
  json5                          0.9.17           pyhd8ed1ab_0        conda-forge
  jsonpointer                    2.4              py311h38be061_3     conda-forge
  jsonschema                     4.21.1           pyhd8ed1ab_0        conda-forge
  jsonschema-specifications      2023.12.1        pyhd8ed1ab_0        conda-forge
  jsonschema-with-format-nongpl  4.21.1           pyhd8ed1ab_0        conda-forge
  jupyter-lsp                    2.2.3            pyhd8ed1ab_0        conda-forge
  jupyter_client                 8.6.0            pyhd8ed1ab_0        conda-forge
  jupyter_core                   5.7.1            py311h38be061_0     conda-forge
  jupyter_events                 0.9.0            pyhd8ed1ab_0        conda-forge
  jupyter_server                 2.12.5           pyhd8ed1ab_0        conda-forge
  jupyter_server_terminals       0.5.2            pyhd8ed1ab_0        conda-forge
  jupyter_telemetry              0.1.0            pyhd8ed1ab_1        conda-forge
  jupyterhub                     4.0.2            pyh31011fe_0        conda-forge
  jupyterhub-base                4.0.2            pyh31011fe_0        conda-forge
  jupyterlab                     4.1.2            pyhd8ed1ab_0        conda-forge
  jupyterlab_pygments            0.3.0            pyhd8ed1ab_1        conda-forge
  jupyterlab_server              2.25.3           pyhd8ed1ab_0        conda-forge
  keyutils                       1.6.1            h166bdaf_0          conda-forge
  krb5                           1.21.2           h659d440_0          conda-forge
  ld_impl_linux-64               2.40             h41732ed_0          conda-forge
  libcurl                        8.5.0            hca28451_0          conda-forge
  libedit                        3.1.20191231     he28a2e2_2          conda-forge
  libev                          4.33             hd590300_2          conda-forge
  libexpat                       2.5.0            hcb278e6_1          conda-forge
  libffi                         3.4.2            h7f98852_5          conda-forge
  libgcc-ng                      13.2.0           h807b86a_5          conda-forge
  libgomp                        13.2.0           h807b86a_5          conda-forge
  libnghttp2                     1.58.0           h47da74e_1          conda-forge
  libnsl                         2.0.1            hd590300_0          conda-forge
  libsodium                      1.0.18           h36c2ea0_1          conda-forge
  libsqlite                      3.45.1           h2797004_0          conda-forge
  libssh2                        1.11.0           h0841786_0          conda-forge
  libstdcxx-ng                   13.2.0           h7e041cc_5          conda-forge
  libuuid                        2.38.1           h0b41bf4_0          conda-forge
  libuv                          1.46.0           hd590300_0          conda-forge
  libxcrypt                      4.4.36           hd590300_1          conda-forge
  libzlib                        1.2.13           hd590300_5          conda-forge
  mako                           1.3.2            pyhd8ed1ab_0        conda-forge
  markupsafe                     2.1.5            py311h459d7ec_0     conda-forge
  matplotlib-inline              0.1.6            pyhd8ed1ab_0        conda-forge
  mistune                        3.0.2            pyhd8ed1ab_0        conda-forge
  nbclient                       0.8.0            pyhd8ed1ab_0        conda-forge
  nbconvert-core                 7.16.1           pyhd8ed1ab_0        conda-forge
  nbformat                       5.9.2            pyhd8ed1ab_0        conda-forge
  ncurses                        6.4              h59595ed_2          conda-forge
  nest-asyncio                   1.6.0            pyhd8ed1ab_0        conda-forge
  nodejs                         20.9.0           hb753e55_0          conda-forge
  notebook                       7.1.1            pyhd8ed1ab_0        conda-forge
  notebook-shim                  0.2.4            pyhd8ed1ab_0        conda-forge
  oauthlib                       3.2.2            pyhd8ed1ab_0        conda-forge
  openssl                        3.2.1            hd590300_0          conda-forge
  overrides                      7.7.0            pyhd8ed1ab_0        conda-forge
  packaging                      23.2             pyhd8ed1ab_0        conda-forge
  pamela                         1.1.0            pyh1a96a4e_0        conda-forge
  pandocfilters                  1.5.0            pyhd8ed1ab_0        conda-forge
  parso                          0.8.3            pyhd8ed1ab_0        conda-forge
  pexpect                        4.9.0            pyhd8ed1ab_0        conda-forge
  pickleshare                    0.7.5            py_1003             conda-forge
  pip                            24.0             pyhd8ed1ab_0        conda-forge
  pkgutil-resolve-name           1.3.10           pyhd8ed1ab_1        conda-forge
  platformdirs                   4.2.0            pyhd8ed1ab_0        conda-forge
  prometheus_client              0.20.0           pyhd8ed1ab_0        conda-forge
  prompt-toolkit                 3.0.42           pyha770c72_0        conda-forge
  psutil                         5.9.8            py311h459d7ec_0     conda-forge
  ptyprocess                     0.7.0            pyhd3deb0d_0        conda-forge
  pure_eval                      0.2.2            pyhd8ed1ab_0        conda-forge
  pycparser                      2.21             pyhd8ed1ab_0        conda-forge
  pycurl                         7.45.3           py311h3393d6f_0     conda-forge
  pygments                       2.17.2           pyhd8ed1ab_0        conda-forge
  pyjwt                          2.8.0            pyhd8ed1ab_1        conda-forge
  pyopenssl                      24.0.0           pyhd8ed1ab_0        conda-forge
  pysocks                        1.7.1            pyha2e5f31_6        conda-forge
  python                         3.11.8           hab00c5b_0_cpython  conda-forge
  python-dateutil                2.8.2            pyhd8ed1ab_0        conda-forge
  python-fastjsonschema          2.19.1           pyhd8ed1ab_0        conda-forge
  python-json-logger             2.0.7            pyhd8ed1ab_0        conda-forge
  python_abi                     3.11             4_cp311             conda-forge
  pytz                           2024.1           pyhd8ed1ab_0        conda-forge
  pyyaml                         6.0.1            py311h459d7ec_1     conda-forge
  pyzmq                          25.1.2           py311h34ded2d_0     conda-forge
  readline                       8.2              h8228510_1          conda-forge
  referencing                    0.33.0           pyhd8ed1ab_0        conda-forge
  requests                       2.31.0           pyhd8ed1ab_0        conda-forge
  rfc3339-validator              0.1.4            pyhd8ed1ab_0        conda-forge
  rfc3986-validator              0.1.1            pyh9f0ad1d_0        conda-forge
  rpds-py                        0.18.0           py311h46250e7_0     conda-forge
  ruamel.yaml                    0.18.6           py311h459d7ec_0     conda-forge
  ruamel.yaml.clib               0.2.8            py311h459d7ec_0     conda-forge
  send2trash                     1.8.2            pyh41d4057_0        conda-forge
  setuptools                     69.1.1           pyhd8ed1ab_0        conda-forge
  six                            1.16.0           pyh6c4a22f_0        conda-forge
  sniffio                        1.3.1            pyhd8ed1ab_0        conda-forge
  soupsieve                      2.5              pyhd8ed1ab_1        conda-forge
  sqlalchemy                     2.0.27           py311h459d7ec_0     conda-forge
  stack_data                     0.6.2            pyhd8ed1ab_0        conda-forge
  terminado                      0.18.0           pyh0d859eb_0        conda-forge
  tinycss2                       1.2.1            pyhd8ed1ab_0        conda-forge
  tk                             8.6.13           noxft_h4845f30_101  conda-forge
  tomli                          2.0.1            pyhd8ed1ab_0        conda-forge
  tornado                        6.4              py311h459d7ec_0     conda-forge
  traitlets                      5.14.1           pyhd8ed1ab_0        conda-forge
  types-python-dateutil          2.8.19.20240106  pyhd8ed1ab_0        conda-forge
  typing-extensions              4.10.0           hd8ed1ab_0          conda-forge
  typing_extensions              4.10.0           pyha770c72_0        conda-forge
  typing_utils                   0.1.0            pyhd8ed1ab_0        conda-forge
  tzdata                         2024a            h0c530f3_0          conda-forge
  uri-template                   1.3.0            pyhd8ed1ab_0        conda-forge
  urllib3                        2.2.1            pyhd8ed1ab_0        conda-forge
  wcwidth                        0.2.13           pyhd8ed1ab_0        conda-forge
  webcolors                      1.13             pyhd8ed1ab_0        conda-forge
  webencodings                   0.5.1            pyhd8ed1ab_2        conda-forge
  websocket-client               1.7.0            pyhd8ed1ab_0        conda-forge
  wheel                          0.42.0           pyhd8ed1ab_0        conda-forge
  xz                             5.2.6            h166bdaf_0          conda-forge
  yaml                           0.2.5            h7f98852_2          conda-forge
  zeromq                         4.3.5            h59595ed_1          conda-forge
  zipp                           3.17.0           pyhd8ed1ab_0        conda-forge
  zlib                           1.2.13           hd590300_5          conda-forge
  zstd                           1.5.5            hfc55251_0          conda-forge

Generated with micromamba create -n jupyterhub -y python=3.11 jupyterhub jupyterlab notebook ipywidgets

DonJayamanne commented 4 months ago

@basnijholt

Thanks for filing this issue and sorry you too are running into this.

FYI - There's no need to create a new issue, If you or others run into the exact same issue, then providing information in the same issue is preferred

basnijholt commented 4 months ago

I am writing documentation on how to use our JupyterHub with VS Code and now add this following warning:

[!WARNING] Currently, opening a notebook in VS Code with a JupyterHub kernel will result in an incorrectly set working directory (issue). This can cause issues with relative file paths and imports. To avoid this problem, it's recommended to use this at the start of your notebook import os; os.chdir('/folder/where/notebook/lives').

Do you perhaps know a better workaround?

DonJayamanne commented 4 months ago

Sorry, but I haven't had a chance to look at this yet, Will look into this today.

dylkot commented 2 months ago

Unfortunately I am having the same issue in a similar remote jupyter environment. Some options I have tried that all similarly return the workspace home folder rather than the notebook directory:

%pwd 

import IPython
IPython.get_ipython().starting_dir

import os
os.getcwd()

I have also confirmed that the "Notebook File Root" setting is ${fileDirname} and not ${workspaceFolder}

any help with this would be greatly appreciated!

basnijholt commented 2 months ago

@DonJayamanne, any suggestions of where to look in debugging this?

DonJayamanne commented 2 months ago

@basnijholt

I have also confirmed that the "Notebook File Root" setting is ${fileDirname} and not ${workspaceFolder}

This does not work with remote servers.

Looks like the issue you are running into is https://github.com/microsoft/vscode-jupyter/issues/8771

DonJayamanne commented 1 day ago

Found that this isn't an issue with VS Code, but thats just how Jupyter Hub works. Closing in favour of https://github.com/microsoft/vscode-jupyter/issues/8771 You can optionally change this in JupyterHub via a configuration setting to change the default directory for JupyterLab. Again, this is the behaviour of Jupyter Lab/Hub.