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 envFile cannot use the variable ${fileDirname} #522

Open
snr278 opened this issue May 20, 2020 · 6 comments
Open

launch envFile cannot use the variable ${fileDirname} #522

snr278 opened this issue May 20, 2020 · 6 comments
Assignees
Labels
bug Issue identified by VS Code Team member as probable bug info-needed Issue requires more information from poster needs PR Ready to be worked on

Comments

@snr278
Copy link

snr278 commented May 20, 2020

Environment data

  • VS Code version: 1.45.1(user setup)
  • Extension version (available under the Extensions sidebar): 2020.5.80290
  • OS and version: Windows_NT x64 10.0.17763
  • Python version (& distribution if applicable, e.g. Anaconda): 2.7.5 64-bit
  • Type of virtual environment used (N/A | venv | virtualenv | conda | ...): NA
  • Relevant/affected Python packages and their versions: XXX
  • Relevant/affected Python-related VS Code extensions and their versions: XXX
  • Jedi or Language Server? (i.e. what is "python.jediEnabled" set to; more info How to update the language server to the latest stable version vscode-python#3977): Jedi
  • Value of the python.languageServer setting: Microsoft

Expected behaviour

configurations.envFile can use the variable ${fileDirname} (eg:"envFile": "${fileDirname}/${fileBasenameNoExtension}.env")

Actual behaviour

env variables define in file ${fileDirname}/${fileBasenameNoExtension}.env are not working.

Steps to reproduce:

[NOTE: Self-contained, minimal reproducing code samples are extremely helpful and will expedite addressing your issue]

  1. create test file ${workspaceFolder}/test/test.py ${workspaceFolder}/test/test.env.
    2.test.env define the env variable TEST_ENV_MY=hello world test_env
    3.test.py print the env variable TEST_ENV_MY
    4.define the envFile in launch.json "envFile": "${fileDirname}/.env"

record

Logs

Output for Python in the Output panel (ViewOutput, change the drop-down the upper-right of the Output panel to Python)

XXX


Output from Console under the Developer Tools panel (toggle Developer Tools on under Help; turn on source maps to make any tracebacks be useful by running Enable source map support for extension debugging)

XXXX

@snr278 snr278 added triage-needed Needs assignment to the proper sub-team bug Issue identified by VS Code Team member as probable bug labels May 20, 2020
@kimadeline
Copy link

Hi @snr278,

Thank you for reporting this issue! Seems like we don't interpolate fileDirname correctly.

Notes

  • fileDirname works with Node debugging, whether in the envFile path or as an env variable:

image

  • fileDirname works as an env variable in the Python launch config, but not when in the envFile path:

image

@kimadeline kimadeline removed the triage-needed Needs assignment to the proper sub-team label May 20, 2020
@kimadeline kimadeline removed their assignment Jul 22, 2020
@mattgillard
Copy link

I just came across this bug today. I thought it was just me!

@weinand
Copy link

weinand commented Sep 16, 2020

@kimadeline above you said

"we don't interpolate fileDirname correctly"

Please note that it is dangerous to interpolate variables yourself because you will miss newly introduced variables (and your variable substitution code might differ from VS Code's code).

A fully interpolated launch config is passed into the DebugConfigurationProviders method resolveDebugConfigurationWithSubstitutedVariables. If you are already implementing a method resolveDebugConfiguration then you can just rename that method to resolveDebugConfigurationWithSubstitutedVariables and drop your own variable substitution code.

@kimadeline
Copy link

Thank you for the heads-up @weinand! We indeed use resolveDebugConfiguration, so resolveDebugConfigurationWithSubstitutedVariables is a very likely part of the solution (we still need to investigate further and see if there's anything else that could be causing this issue).

@mattgillard feel free to upvote the issue report to help us prioritize this.

Thanks!

@karrtikr karrtikr added the needs PR Ready to be worked on label Aug 9, 2022
@jtele2
Copy link

jtele2 commented Jan 9, 2023

This seems to work sometimes for me and other times it does not. Any ideas?

@eleanorjboyd
Copy link
Member

Is this still a problem people are facing?

@eleanorjboyd eleanorjboyd added the info-needed Issue requires more information from poster label Dec 12, 2024
@eleanorjboyd eleanorjboyd transferred this issue from microsoft/vscode-python Dec 12, 2024
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 info-needed Issue requires more information from poster needs PR Ready to be worked on
Projects
None yet
Development

No branches or pull requests

9 participants