Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Environment variables persist after being unset #10392

Closed
1 of 2 tasks
benjaminsirb opened this issue Jun 9, 2022 · 10 comments
Closed
1 of 2 tasks

Environment variables persist after being unset #10392

benjaminsirb opened this issue Jun 9, 2022 · 10 comments
Assignees
Labels
bug Issue identified by VS Code Team member as probable bug
Milestone

Comments

@benjaminsirb
Copy link

Applies To

  • Notebooks (.ipynb files)
  • Interactive Window and/or Cell Scripts (.py files with #%% markers)

What happened?

Issue Type: Bug

I have unset environment variables through my CLI but vscode is still picking them up (through the os module in a jupyter notebook). When testing through jupyterlab, the variables do not exist. Same when trying to echo that var through vscode terminal (and native mac terminal).

Extension version: 2022.4.1021342353
VS Code version: Code 1.67.2 (Universal) (c3511e6c69bb39013c4a4b7b9566ec1ca73fc4d5, 2022-05-17T18:20:57.384Z)
OS version: Darwin arm64 21.5.0
Restricted Mode: No

System Info
Item Value
CPUs Apple M1 Max (10 x 24)
GPU Status 2d_canvas: enabled
canvas_oop_rasterization: disabled_off
direct_rendering_display_compositor: disabled_off_ok
gpu_compositing: enabled
metal: disabled_off
multiple_raster_threads: enabled_on
oop_rasterization: enabled
opengl: enabled_on
rasterization: enabled
raw_draw: disabled_off_ok
skia_renderer: enabled_on
video_decode: enabled
video_encode: enabled
webgl: enabled
webgl2: enabled
Load (avg) 3, 4, 5
Memory (System) 32.00GB (14.23GB free)
Process Argv --crash-reporter-id 5ce1fcb7-d020-417d-994f-6b51eee1cb0f
Screen Reader no
VM 0%
A/B Experiments
vsliv368cf:30146710
vsreu685:30147344
python383:30185418
vspor879:30202332
vspor708:30202333
vspor363:30204092
pythonvspyl392:30443607
pythontb:30283811
pythonptprofiler:30281270
vshan820:30294714
vstes263:30335439
pythondataviewer:30285071
vscod805:30301674
binariesv615:30325510
bridge0708:30335490
bridge0723:30353136
vsaa593:30376534
vsc1dst:30438360
pythonvs932:30410667
wslgetstarted:30449410
vscscmwlcmt:30465135
cppdebug:30492333
vsclangdc:30486549

VS Code Version

Version: 1.67.2 (Universal) Commit: c3511e6c69bb39013c4a4b7b9566ec1ca73fc4d5 Date: 2022-05-17T18:20:57.384Z (3 wks ago) Electron: 17.4.1 Chromium: 98.0.4758.141 Node.js: 16.13.0 V8: 9.8.177.13-electron.0 OS: Darwin arm64 21.5.0

Jupyter Extension Version

v2022.4.1021342353

Jupyter logs

No response

Coding Language and Runtime Version

python 3.8.11

Language Extension Version (if applicable)

No response

Anaconda Version (if applicable)

No response

Running Jupyter locally or remotely?

Local

@benjaminsirb benjaminsirb added bug Issue identified by VS Code Team member as probable bug triage-needed Issue needs to be triaged labels Jun 9, 2022
@IanMatthewHuff
Copy link
Member

@benjaminsirb Could you clarify your scenario here? Not exactly sure what you mean my unsetting them from the CLI. VS Code should be picking up the variables based on the kernel that you have selected.

If you point out the variable in particular you could try grabbing the logs from the Jupyter section of the output window. Then save those logs to a file and attach it to a comment here. I believe that we logged env vars in that logging so maybe I can see what is happening here.

@rchiodo rchiodo added info-needed Issue requires more information from poster and removed triage-needed Issue needs to be triaged labels Jun 9, 2022
@benjaminsirb
Copy link
Author

@IanMatthewHuff Hello, I'm attaching the logs you asked for (please let me know if I misunderstood what you asked for). Also, attaching a screenshot that may help explain. Left window is jupyter lab, bottom right window is vscode, both running the same notebook / cell, same kernel. Also including my terminal output to illustrate that TEST_VAR does not exist (and I believe I'm operating from the correct kernel / environment), but vscode is still picking it up from somewhere.
logs.txt
Screen Shot 2022-06-10 at 8 02 36 AM

@IanMatthewHuff
Copy link
Member

@benjaminsirb I believe that the issue here is that vscode doesn't pick up environmental variables from the terminal process that it was launched from. JupyterLab launches in the context of the terminal window where you have unset the Env Vars. But vscode won't have any knowledge of this unsetting. I has to work this way as VS Code can launch once and then start multiple different kernels from the same UI instance. But JupyterLab is just picking up the single terminal env that it's launched from.

@DonJayamanne
Copy link
Contributor

DonJayamanne commented Jun 11, 2022

looks like this is related to #9682
hopefully this will be fixed in the next iteration

@lukehuxham
Copy link

I wanted to add to this issue as I feel its related. I have changed an environment variable and jupyter will not see the new value. It must be caching the value somewhere but cannot figure it out. I have restarted my mac and still doesn't work. Starting a terminal in VSCode, spawning python in terminal both see the new value but jupyter is seeing the old value. Please advise on any information i can give to help bug fix this

@DonJayamanne
Copy link
Contributor

@lukehuxham how are you setting the new env variable. Are you changing this env variable in your shell login script like .zshrc or bashrc file or the like?

@lukehuxham
Copy link

@DonJayamanne I modified the variable in my .zshrc file. I have sourced the file as well as restarted the laptop multiple times.

@DonJayamanne DonJayamanne added this to the July 2022 milestone Jul 11, 2022
@DonJayamanne
Copy link
Contributor

@lukehuxham Please could you

  • Run a notebook cell that prints the value of the env variable in question
  • Upload all of the output from Juptyer output panel (use the command Jupyter:Show Output to get to that.

@DonJayamanne
Copy link
Contributor

Should be fixed with #10843
Please try this in the latest pre-release version of the Jupyter extension (in vscode insiders)

@rebornix rebornix added verified Verification succeeded verification-steps-needed Steps to verify are needed for verification and removed verified Verification succeeded labels Jul 28, 2022
@rebornix
Copy link
Member

@DonJayamanne do you have steps for how to verify this parituclar issue?

@rzhao271 rzhao271 removed the info-needed Issue requires more information from poster label Jul 28, 2022
@DonJayamanne DonJayamanne removed the verification-steps-needed Steps to verify are needed for verification label Jan 29, 2023
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Sep 9, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
bug Issue identified by VS Code Team member as probable bug
Projects
None yet
Development

No branches or pull requests

7 participants