You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Log the user's environment when the attempt to execute pipenv returns ENOENT #1338
I'm assuming pipenv --venv works only after you have setup the above environment variable.
Can you not add the above environment variable in your ~/.bash_profile file or similar?
Please try re-starting VS Code, ensure you have quit VS Code completely for the VS Code process to load the new environment variable.
Once done, please test once again.
Ok, I believe know whats going on.
I believe this is similar to #1027 & #1254
Please could you add the necessary environment variables as defined here: http://click.pocoo.org/5/python3/
You can see how it was solved in #1027 as well.
Let me know how that goes.
This did not work. Exported variables in bashrc. Logged out. Logged back in. Launched VSCode. I think an important discrepancy between my issue and the #1027 is that pipenv --venv works if pipenv is located in /usr/bin/ from what I remember. Attached screenshot to prove variables were set upon launch.
OK, so my best account of what's happening is this:
VSCode is launched via the code bash script
the shell which runs that script is non-interactive (obviously, it's a script) and non-login, so on its own, it doesn't source ~/.bashrc nor ~/.bash_profile nor ~/.profile
in other words, the only way for that shell to know about customizations performed in these startup files is to inherit them from the parent environment, which works fine if you run the code script from an interactive shell
however, on my system (Solus OS), when I start VSCode via a .desktop file (e.g. from an application launcher), the code script runs in an environment in which the user's shell startup files haven't been sourced, so the customizations just aren't there for the code script to inherit
I think the easiest solution here is just to source "$HOME/.bashrc" at the start of the code script, so that you get the same environment as the one you use in interactive shells (it's not just about the PATH, there are other relevant variables like WORKON_HOME for virtualenvs etc.).
Incidentally, tweaking the code script is also a convenient way of ensuring that VSCode works with your setup if you're using a different shell than bash (zsh in my case, as mentioned in my previous comment -- I just changed the shebang to #!/bin/zsh and everything seems to work).
One last thing: I was also getting a UnicodeDecodeError: 'ascii' codec can't decode byte... on a different box running macOS (from click, when VSCode was trying to run pipenv). This pointed to a misconfigured locale, i.e. another type of environment problem. I ran chsh, which informed me that my login shell was bash, and the crux of the biscuit was that I hadn't bothered to properly configure the locale in bash because I use zsh on that system. Troubleshooting:
running code from a zsh command line, the error goes away
more generally, changing my login shell to zsh (using chsh) makes the problem go away, irrespective of how VSCode is started
In any case, getting rid of this type of error is about running VSCode in the proper environment, i.e. the one you use in your interactive terminal sessions. These last two posts of mine are just a laundry list of things you might want to check and tweak in order to make that happen :)
David Lukes (@dlukes) thanks for all the exploration! We obviously don't control the code command, so feel free to report that upstream to VS Code if you would like to see this changed.
And as for the locale issues, we plan to at least log if not warn users when we discover their locale isn't set such that click will have an issue.
I don't think this can be made to work automatically for everyone everywhere, as there's just too much variety in the kinds of setups people use, especially on Unix-like systems. But I do think users could be made more aware of this type of issues, and they could be given more convenient tools to address them, so I submitted a report to that effect upstream microsoft/vscode#50465 :) You're more than welcome to chime in!
Activity
MikhailArkhipov commentedon Apr 7, 2018
So if you run
pipenv --venvfrom the workspace folder it does succeed?tristan957 commentedon Apr 10, 2018
Yes the command succeeds
DonJayamanne commentedon Apr 10, 2018
I'm assuming
pipenv --venvworks only after you have setup the above environment variable.Can you not add the above environment variable in your
~/.bash_profilefile or similar?tristan957 commentedon Apr 10, 2018
My bash profile is sourcing my bashrc where I am exporting the above path variable
DonJayamanne commentedon Apr 10, 2018
Please try re-starting VS Code, ensure you have quit VS Code completely for the VS Code process to load the new environment variable.
Once done, please test once again.
tristan957 commentedon Apr 10, 2018
I have restarted my computer within the last 3 days many times. I experienced this same issue a few hours ago.
DonJayamanne commentedon Apr 10, 2018
Ok, I believe know whats going on.
I believe this is similar to #1027 & #1254
Please could you add the necessary environment variables as defined here: http://click.pocoo.org/5/python3/
You can see how it was solved in #1027 as well.
Let me know how that goes.
tristan957 commentedon Apr 10, 2018
This did not work. Exported variables in bashrc. Logged out. Logged back in. Launched VSCode. I think an important discrepancy between my issue and the #1027 is that
pipenv --venvworks ifpipenvis located in/usr/bin/from what I remember. Attached screenshot to prove variables were set upon launch.47 remaining items
dlukes commentedon May 18, 2018
OK, so my best account of what's happening is this:
codebash script~/.bashrcnor~/.bash_profilenor~/.profilecodescript from an interactive shell.desktopfile (e.g. from an application launcher), thecodescript runs in an environment in which the user's shell startup files haven't been sourced, so the customizations just aren't there for thecodescript to inheritI think the easiest solution here is just to
source "$HOME/.bashrc"at the start of thecodescript, so that you get the same environment as the one you use in interactive shells (it's not just about thePATH, there are other relevant variables likeWORKON_HOMEfor virtualenvs etc.).Incidentally, tweaking the
codescript is also a convenient way of ensuring that VSCode works with your setup if you're using a different shell thanbash(zshin my case, as mentioned in my previous comment -- I just changed the shebang to#!/bin/zshand everything seems to work).Add LC_ALL and LANG environment variables
dlukes commentedon May 22, 2018
One last thing: I was also getting a
UnicodeDecodeError: 'ascii' codec can't decode byte...on a different box running macOS (fromclick, when VSCode was trying to runpipenv). This pointed to a misconfigured locale, i.e. another type of environment problem. I ranchsh, which informed me that my login shell wasbash, and the crux of the biscuit was that I hadn't bothered to properly configure the locale inbashbecause I usezshon that system. Troubleshooting:codefrom azshcommand line, the error goes awayzsh(usingchsh) makes the problem go away, irrespective of how VSCode is startedIn any case, getting rid of this type of error is about running VSCode in the proper environment, i.e. the one you use in your interactive terminal sessions. These last two posts of mine are just a laundry list of things you might want to check and tweak in order to make that happen :)
brettcannon commentedon May 23, 2018
David Lukes (@dlukes) thanks for all the exploration! We obviously don't control the
codecommand, so feel free to report that upstream to VS Code if you would like to see this changed.And as for the locale issues, we plan to at least log if not warn users when we discover their locale isn't set such that
clickwill have an issue.tristan957 commentedon May 24, 2018
David Lukes (@dlukes) can you link the issue here when you open it in the vscode repo, or subscribe me to the issue?
dlukes commentedon May 25, 2018
I don't think this can be made to work automatically for everyone everywhere, as there's just too much variety in the kinds of setups people use, especially on Unix-like systems. But I do think users could be made more aware of this type of issues, and they could be given more convenient tools to address them, so I submitted a report to that effect upstream microsoft/vscode#50465 :) You're more than welcome to chime in!
DonJayamanne commentedon Jun 14, 2018
Modified to log the following env variables:
PATHLC_ALLLANGLog env info when the existence of pipenv cannot be determined (#1962)