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 variable definitions file substitution does not work when debugging a Python file #159

Open
emptyVoid opened this issue May 21, 2019 · 6 comments
Assignees
Labels
bug Issue identified by VS Code Team member as probable bug needs PR Ready to be worked on

Comments

@emptyVoid
Copy link

Environment data

  • VS Code version: Code 1.34.0 (a622c65b2c713c890fcf4fbf07cf34049d5fe758, 2019-05-15T21:59:37.030Z)
  • Extension version (available under the Extensions sidebar): 2019.4.12954
  • OS and version: Windows x64 10.0.17763
  • Python version (& distribution if applicable, e.g. Anaconda): 3.6
  • Type of virtual environment used (N/A | venv | virtualenv | conda | ...): venv

Expected behaviour

According to documentation the value of any existing environment variable could be used when defining an environment variables.

Actual behaviour

Value of PATH environment variable is not being substituted.

Steps to reproduce:

  1. Create .env file with a single line PATH="${PATH};Blah-blah-blah".
  2. Print PATH value with print(os.environ.get('PATH'))
  3. ;Blah-blah-blah gets printed.
@karrtikr
Copy link
Contributor

Print PATH value with print(os.environ.get('PATH'))

How are you running this command. Are you using Run python file in terminal ,i.e running directly in terminal.
Or are you using the Python debugger (running by debugging). Resolution currently only works in debugger.

@emptyVoid
Copy link
Author

I'm running it under debugger with this launch configuration:

{
    "name": "Python: Module",
    "type": "python",
    "request": "launch",
    "module": "blah",
    "console": "integratedTerminal"
}

@karrtikr karrtikr removed their assignment May 23, 2019
@int19h
Copy link

int19h commented Jul 8, 2020

This works if you do {env:PATH}.

However, this is not standard syntax. We should probably follow python-dotenv syntax on this: https://pypi.org/project/python-dotenv/

@luabud
Copy link
Member

luabud commented Jul 8, 2020

I opened microsoft/vscode-docs#3856 to track the documentation update that is required.

Related: microsoft/vscode-python#11812

@karrtikr karrtikr changed the title Environment variable definitions file: Substitution does not work for PATH Environment variable definitions file substitution does not work when debugging Jan 18, 2022
@karrtikr karrtikr changed the title Environment variable definitions file substitution does not work when debugging Environment variable definitions file substitution does not work when debugging a Python file Jan 18, 2022
@karrtikr
Copy link
Contributor

karrtikr commented Jan 18, 2022

This works if you do {env:PATH}.

@int19h This actually does not work if specified in a .env file. Weirdly it works when debugging a test via the debug launcher but not when debugging a Python file. I'm transferring this issue to debugpy as I believe it has its own environment variable resolver.

@int19h
Copy link

int19h commented Feb 22, 2022

debugpy does not have its own variable substitution logic - it's entirely a VSCode thing. Ditto for "envfile" - debugpy expects to receive everything already fully expanded and substituted in "env".

@judej judej transferred this issue from microsoft/debugpy Feb 23, 2022
@github-actions github-actions bot added the triage-needed Needs assignment to the proper sub-team label Feb 23, 2022
@karthiknadig karthiknadig added bug Issue identified by VS Code Team member as probable bug and removed triage-needed Needs assignment to the proper sub-team labels Feb 24, 2022
@karrtikr karrtikr removed their assignment Feb 24, 2022
@karrtikr karrtikr added the needs PR Ready to be worked on label Aug 9, 2022
@paulacamargo25 paulacamargo25 transferred this issue from microsoft/vscode-python Dec 14, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Issue identified by VS Code Team member as probable bug needs PR Ready to be worked on
Projects
None yet
Development

No branches or pull requests

7 participants