Make environment issues easier to troubleshoot #50465
Labels
feature-request
Request for new features or functionality
*out-of-scope
Posted issue is not in scope of VS Code
I recently started using VSCode and I've been very happy for the most part (kudos and thank you!) :) However, there was one hurdle that made the initial setup somewhat painful: my environment variables weren't being properly picked up.
By "properly picked up", I mean "the same as in the shell I use day to day". Many VSCode extensions run commands on behalf of the user, which they can't do if the command lives in a non-standard directory and the configuration which puts that directory on the
PATH
is ignored. Or the command itself may live in a standard directory, but it may be influenced by some other environment variableFOO
, in the absence of which its outcome is different. Getting different behavior when running the same command from my shell and from VSCode is confusing, and currently hard to troubleshoot.I expect this is a problem mostly on Unix-like systems, where people regularly use a variety of shells and different ways to configure them. I'm afraid there's no foolproof way for VSCode to just guess the correct setup here. But it would be great to make users more aware that some of the problems they might encounter while running VSCode arise from improperly detected environments, and there should be more convenient tools to address them (see below for suggestions).
One concrete example is microsoft/vscode-python#1338, my own attempts to work around the problem are documented in a few comments starting here. Based on that experience, I've distilled some ideas for features that I think would make it easier to resolve this type of issues:
settings.json
-- just an object where you can set/override any environment variableenv
and copy-paste the output, which will be parsed and put into theirsettings.json
(see previous bullet); obviously, this is for Unix-like systems, I'm not sure what the Windows equivalent would beIn addition to the quick-and-dirty fix via
settings.json
, it would be great to have a page in the docs on other ways to address this kind of problems, including:code
script -- changing the shebang to use the shell you normally use (bash
→zsh
in my case), explicitly sourcing the runcoms which contain the appropriate settings etc. (this turned out to be useful on Linux, where VSCode is invoked via the script even when not run from the command line; no idea if that's the case on Windows and macOS)chsh
(this helped me on macOS but not on Solus OS Linux, where it seems like environment customizations made in the login shell runcoms are not transferred to the GUI environment)It's not like VSCode needs to have all of these, they're more food for thought / inspiration :) And thanks again for a great editor!
The text was updated successfully, but these errors were encountered: