question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Support remote server being treated like a 'local' server when on same machine as VS code extension host

See original GitHub issue

Current Working Directory is not the current notebook directory.

This goes against default behaviour in jupyter notebook and jupyter lab.

Can this be fixed? If not, how can I automate setting the current work directory to the file location? Is there some environment variable that is set to the current notebook file that I can read in a setup cell?

Environment data

  • VS Code version: 1.61.1
  • Jupyter Extension version (available under the Extensions sidebar): v2021.9.1101343141
  • Python Extension version (available under the Extensions sidebar): v2021.10.1336267007
  • OS (Windows | Mac | Linux distro) and version: Windows 21H1
  • Python and/or Anaconda version: 3.9
  • Type of virtual environment used (N/A | venv | virtualenv | conda | …): conda
  • Jupyter server running: Remote

Expected behaviour

from pathlib import Path; Path.cwd() returns the directory where the current notebook is.

Actual behaviour

The directory where the jupyter remote server was started is returned.

Steps to reproduce:

  1. Externally, start jupyter server at ~
  2. Create folder at ~/a
  3. Create folder at ~/a/b
  4. With vscode remote ssh, open ~/a.
  5. Run vscode command to create notebook at ~/a/b/c.ipynb
  6. In the notebook, run from pathlib import Path; Path.cwd()

Issue Analytics

  • State:closed
  • Created 2 years ago
  • Reactions:3
  • Comments:12 (6 by maintainers)

github_iconTop GitHub Comments

4reactions
TTTPOBcommented, Mar 11, 2022

is there a reason you want the remote server there? Maybe sharing with other people that don’t use VS code?

for me there is just one reason: remote sessions won’t be closed when i close vscode

a job lasting for days is common for me, I can’t keep my laptop connected to the server for like a few days

2reactions
lasergyrocommented, Oct 20, 2021

Regarding getting the server start path: the dummy kernel would work; presumably if vscode sees the kernel file via remote ssh in the same place, then it can assume it is the same machine.

The server is remote because it places the code closer to the data. There’s a few reasons for not wanting to manage jupyter with vscode. Having the lifecycle of VScode tied to Jupyter makes it harder to debug issues that show up in one of them ( jupyter crashes / vscode crashes / vscode ui issues ). I am not even at 50% usage of vscode-jupyter due other issues, and that’s another reason to not want vscode managing it, I often jump back to jupyterlab. I often leave the jupyter server running while I have closed vscode, either finishing some computation or because my client machine was powered off.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Remote Development FAQ - Visual Studio Code
Remote Development FAQ. This article covers frequently asked questions for each of the Visual Studio Code Remote Development extensions.
Read more >
Remote Development using SSH - Visual Studio Code
The Visual Studio Code Remote - SSH extension allows you to open a remote folder on any remote machine, virtual machine, or container...
Read more >
Supporting Remote Development and GitHub Codespaces
UI Extensions are run in VS Code's local Extension Host, while Workspace Extensions are run in a Remote Extension Host that sits in...
Read more >
Visual Studio Code Server
The Visual Studio Code Server is a service you can run on a remote development machine, like your desktop PC or a virtual...
Read more >
Extension Host - Visual Studio Code
The Visual Studio Code Extension Host is responsible for managing extensions and ensuring the stability and performance of Visual Studio Code.
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found