hiroshinishio / vscode

Visual Studio Code
https://code.visualstudio.com
MIT License
0 stars 0 forks source link

When using VS Code with a remote server (via SSH), Jupyter Notebook’s working directory does not correctly reflect the directory where the .ipynb file is located. Instead, %pwd always returns the path to the root of the workspace (e.g., Src), regardless of the location of the opened notebook file. #12

Open hiroshinishio opened 2 weeks ago

hiroshinishio commented 2 weeks ago

Does this issue occur when all extensions are disabled?: when I run %pwd at local home/Src/ray/a.ipynb, return home/Src/ray as expected.

Problem: When using VS Code with a remote server (via SSH), Jupyter Notebook’s working directory does not correctly reflect the directory where the .ipynb file is located. Instead, %pwd always returns the path to the root of the workspace (e.g., Src), regardless of the location of the opened notebook file.

Environment: • Local OS Version: macOS Sonoma 14.6.1, M1pro • VS Code Version: 1.92.2 (Universal) • Remote Extension: Remote - SSH latest version • Jupyter Extension Version: latest • Remote Server OS: Scientific Linux 7.9 (Nitrogen), based on: RHEL, CentOS, Fedora • Jupyter Notebook Version: IPython : 8.26.0 ipykernel : 6.29.5 ipywidgets : 8.1.3 jupyter_client : 8.6.2 jupyter_core : 5.7.2 jupyter_server : 2.14.2 jupyterlab : 4.2.4 nbclient : 0.10.0 nbconvert : 7.16.4 nbformat : 5.10.4 notebook : 7.2.1 qtconsole : 5.5.2 traitlets : 5.14.3

Steps to Reproduce:

1.  Open VS Code and connect to a remote server using SSH.
2.  Navigate to a subdirectory (e.g., home/user/Src/ray) and open a Jupyter Notebook file (a.ipynb).
3.  Run %pwd in a cell of the notebook.

Expected Behavior: %pwd should return the path to the ray directory (where a.ipynb is located).

Actual Behavior: %pwd returns Src, the root directory of the workspace, instead of the directory containing the notebook file.

Solutions Attempted

1.  Configured VS Code Remote Settings:
•   Added "jupyter.notebookFileRoot": "${fileDirname}" to .vscode/settings.json and verified in both local and remote workspace settings.
2.  Manually Changed Working Directory:
•   Used %cd {fileDirname} in the notebook to manually change the directory, but this is not an automatic solution.
3.  Deleted and Reinstalled VS Code Server:
•   Uninstalled VS Code Server by removing the .vscode-server directory on the remote server and reinstalled it by reconnecting to the server, but the issue persists.
4.  Verified and Updated Extensions:
•   Ensured that both the Remote - SSH and Jupyter extensions are up to date.
    5.     run %pwd a.ipynb at local home/Src/ray/a.ipynb
    •   return home/Src/ray as expected.

Request for Help

Despite trying the above solutions, the working directory in Jupyter Notebook does not reflect the location of the a.ipynb file. Assistance in resolving this issue or any additional suggestions would be greatly appreciated.

gitauto-for-dev[bot] commented 2 weeks ago

Welcome to GitAuto! 🎉 Click the checkbox below to generate a PR!

gitauto-ai[bot] commented 2 weeks ago

Click the checkbox below to generate a PR!

@hiroshinishio, You have 0 requests left in this cycle which refreshes on 2024-09-04 02:56:25+00:00. If you have any questions or concerns, please contact us at info@gitauto.ai.

gitauto-ai[bot] commented 2 weeks ago

Sorry, we have an error. Please try again.

Have feedback or need help? Feel free to email info@gitauto.ai.