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.

Working directory for non-python kernels in a temp directory

See original GitHub issue

Bug: Notebook Editor, Interactive Window, Editor cells

Steps to cause the bug to occur

  1. Create a new jupyter notebook and save it in a file location, or open an existing file
  2. Change the kernel to something already installed (e.g. Julia 1.4.2 in my case)
  3. Run pwd() to see the working directory

Actual behavior

I am getting C:\\Users\\MYUSERNAME\\AppData\\Local\\Temp\\7bb05f8c-bf2c-4a11-b590-de1cdae0d271 as the path.

This is especially important for Julia since the jupyter kernel activates a Project.toml and Manifest.toml local to the path of a file when it starts. This makes reproducible packages/etc. possible, and is difficult to do after startup.

Expected behavior

It should be be where the file is opened or saved. In my case, 'c:\\Users\\MYUSERNAME\\Documents\\GitHub\\sandbox'

This is what happens with python kernels, for example. In that case, ;pwd returns that string.

Your Jupyter and/or Python environment

  • Jupyter server running: Local
  • Extension version: 2020.6.91350
  • VS Code version: 1.46.1
  • Setting python.jediEnabled: false
  • Python and/or Anaconda version: 3.7.4 64 bit conda
  • OS: Windows
  • Virtual environment: conda

Microsoft Data Science for VS Code Engineering Team: @rchiodo, @IanMatthewHuff, @DavidKutu, @DonJayamanne, @greazer, @joyceerhl

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Comments:18 (11 by maintainers)

github_iconTop GitHub Comments

2reactions
stevengjcommented, Jul 8, 2020

Why can’t you set the working directory to that of the notebook before executing the kernel-launch command? That’s what Jupyter does…

1reaction
IanMatthewHuffcommented, Aug 12, 2020

Since the change here is in the Python extension then you would actually need the insiders version of our extension (can use that with either normal VS Code or VS Code - insiders). Info is on this here: https://github.com/microsoft/vscode-python/blob/master/CONTRIBUTING.md#development-build It’s very easy to swap that back to the release version, so it’s safe to use that to test if you want.

I believe that this should work with github codespaces, I’ve not tested that myself, but it’s not using anything that would prevent that. However I would assume that github codespaces doesn’t have the insiders version of our extension, so you would not see the fix there yet.

Read more comments on GitHub >

github_iconTop Results From Across the Web

tempfile — Generate temporary files and directories
This module creates temporary files and directories. It works on all supported platforms. TemporaryFile , NamedTemporaryFile , TemporaryDirectory , and ...
Read more >
Current working directory for jupyter notebook sets to temp ...
I use ${fileDirname} in python.dataScience.notebookFileRoot setting. However it uses temporary folder as ${fileDirname} instead of original file ...
Read more >
Can we make a custom directory in our kernel?
Hi All,. I am working on images data and trying to save the results to the 'preview/' directory as below- os.makedirs('../input/preview').
Read more >
Enhance kernels with magic commands - Amazon EMR
EMR Studio and EMR Notebooks support magic commands, which are enhancements provided by the IPython kernel to help run and analyze data.
Read more >
How to fix Kernel Error or broken Python in Jupyter Notebook
TL;DW BELOW! If you delete or upgrade your python version, you might get a Kernel Error when trying to use Jupyter Notebooks!
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