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

launch.json environment variables not being passed to Python scripts #22462

Closed
oleg-korshunov opened this issue Nov 12, 2023 · 6 comments
Closed
Assignees
Labels
area-debugging triage-needed Needs assignment to the proper sub-team

Comments

@oleg-korshunov
Copy link

oleg-korshunov commented Nov 12, 2023

Type: Bug

Behaviour

Expected vs. Actual

XXX

Steps to reproduce:

  1. the bug occurs when you change the standard terminal powershell -> git bash, after restart pc, and environment variables not being passed to Python scripts with git bash and if I select powershell or other terminal ...
# launch.json
{
    "version": "0.2.0",
    "configurations": [
        {
            "name": "Python: Current File",
            "type": "python",
            "request": "launch",
            "program": "${file}",
            "console": "integratedTerminal",
            "justMyCode": true,
            "env": {
                "aaaa123":"dsdsadasadsa"
            }
        }
    ]
}
import os
if __name__=='__main__':    
    print(os.environ["aaaa123"]) # <- key error 

image

Diagnostic data

  • Python version (& distribution if applicable, e.g. Anaconda): 3.11.6
  • Type of virtual environment used (e.g. conda, venv, virtualenv, etc.): Global
  • Value of the python.languageServer setting: Default
Output for Python in the Output panel (ViewOutput, change the drop-down the upper-right of the Output panel to Python)

XXX

User Settings


languageServer: "Pylance"

Extension version: 2023.20.0
VS Code version: Code 1.84.2 (1a5daa3a0231a0fbba4f14db7ec463cf99d7768e, 2023-11-09T10:51:52.184Z)
OS version: Windows_NT x64 10.0.19045
Modes:

System Info
Item Value
CPUs 11th Gen Intel(R) Core(TM) i5-11500H @ 2.90GHz (12 x 2918)
GPU Status 2d_canvas: enabled
canvas_oop_rasterization: enabled_on
direct_rendering_display_compositor: disabled_off_ok
gpu_compositing: enabled
multiple_raster_threads: enabled_on
opengl: enabled_on
rasterization: enabled
raw_draw: disabled_off_ok
video_decode: enabled
video_encode: enabled
vulkan: disabled_off
webgl: enabled
webgl2: enabled
webgpu: enabled
Load (avg) undefined
Memory (System) 15.73GB (9.71GB free)
Process Argv --crash-reporter-id c74c0958-b4d9-43a2-b858-690714d38951
Screen Reader no
VM 0%
A/B Experiments
vsliv368cf:30146710
vsreu685:30147344
python383cf:30185419
vspor879:30202332
vspor708:30202333
vspor363:30204092
vslsvsres303:30308271
vserr242:30382549
pythontb:30283811
vsjup518:30340749
pythonptprofiler:30281270
vsdfh931cf:30280410
vshan820:30294714
vstes263:30335439
vscoreces:30445986
vscod805cf:30301675
binariesv615:30325510
bridge0708:30335490
bridge0723:30353136
vsaa593cf:30376535
pythonvs932:30410667
py29gd2263cf:30880073
vsclangdc:30486549
c4g48928:30535728
dsvsc012:30540252
pynewext54:30695312
azure-dev_surveyone:30548225
282f8724:30602487
f6dab269:30613381
vscrp:30673768
showlangstatbar:30737416
pythonfmttext:30731395
fixshowwlkth:30771522
showindicator:30805244
pythongtdpath:30769146
i26e3531:30792625
pythonnosmt12:30797651
pythonidxpt:30866567
pythonnoceb:30805159
dsvsc013:30795093
dsvsc014:30804076
dsvsc015:30845448
pythontestfixtcf:30871695
pythonregdiag2:30871582
pyreplss2:30886141
pythonmypyd1:30879173
pythoncet0:30885854
h48ei257:30885898
pythontbext0:30879054
accentitlementst:30887150
dsvsc016:30886110
dsvsc017cf:30886113
dsvsc018cf:30886115
aa_t_chat:30882232

I readed the issue #6986 but problem not gone ..

@github-actions github-actions bot added the triage-needed Needs assignment to the proper sub-team label Nov 12, 2023
@karrtikr
Copy link

#3035 #15799 Git bash is not supported by the Python extension, hence please switch your default shell using Terminal: Select default profile to cmd or powershell on windows and report us back if the problem reoccurs.

@karrtikr karrtikr closed this as not planned Won't fix, can't repro, duplicate, stale Nov 13, 2023
@github-actions github-actions bot added the info-needed Issue requires more information from poster label Nov 13, 2023
@oleg-korshunov
Copy link
Author

oleg-korshunov commented Nov 14, 2023

#3035 #15799 Git bash is not supported by the Python extension, hence please switch your default shell using Terminal: Select default profile to cmd or powershell on windows and report us back if the problem reoccurs.

Yes if I do again powershell or cmd, then the settings do not return to default, i.e. when I open a new terminal (powershell or cmd) launch.json environment variables not being passed to Python scripts

Also I completely reinstalled vscode but it doesn't helped ( I removed folders with settings.json and with installed extensions)

@github-actions github-actions bot removed the info-needed Issue requires more information from poster label Nov 14, 2023
@karrtikr
Copy link

the bug occurs when you change the standard terminal powershell -> git bash

You mentioned in the original bug report that it works for Powershell but issue starts happening when shell is changed to git bash. Is it now not working even for Powershell?

@github-actions github-actions bot added the info-needed Issue requires more information from poster label Nov 14, 2023
@oleg-korshunov
Copy link
Author

oleg-korshunov commented Nov 15, 2023

the bug occurs when you change the standard terminal powershell -> git bash

You mentioned in the original bug report that it works for Powershell but issue starts happening when shell is changed to git bash. Is it now not working even for Powershell?

Yes, I installed VSCode on a new computer and worked with PowerShell for a couple of hours. Environment variables from launch.json worked. Then I changed the terminal to Git Bash and the environment variables disappeared. I tried returning to the PowerShell (or CMD) terminal and reinstalling VSCode, but it didn't help. VSCode still doesn't see environment variables from launch.json.

@github-actions github-actions bot removed the info-needed Issue requires more information from poster label Nov 15, 2023
@karrtikr
Copy link

Cool, reopening and reassigning to investigate further in that case.

@karrtikr karrtikr changed the title launch.json environment variables not being passed to Python scripts, the same problem in WSL not only in windows launch.json environment variables not being passed to Python scripts Nov 15, 2023
@karrtikr karrtikr assigned paulacamargo25 and unassigned karrtikr Nov 15, 2023
@oleg-korshunov
Copy link
Author

Cool, reopening and reassigning to investigate further in that case.

Very strange I reinstalled vscode one more time and all fixed 👽

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Dec 30, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
area-debugging triage-needed Needs assignment to the proper sub-team
Projects
None yet
Development

No branches or pull requests

3 participants