Skip to content

Log the user's environment when the attempt to execute pipenv returns ENOENT #1338

Closed

Description

Environment data

  • VS Code version: 1.21.1
  • Extension version (available under the Extensions sidebar): 2018.3.1
  • OS and version: Solus 3.999 (Linux)
  • Python version (& distribution if applicable, e.g. Anaconda): 3.6.4
  • Type of virtual environment used (N/A | venv | virtualenv | conda | ...): pipenv

Actual behavior

Getting a warning saying pipenv is not on path.

Workspace contains pipfile but attempt to run 'pipenv --venv' failed with Error: spawn pipenv ENOENT. Make sure pipenv is on the PATH.
which pipenv

$HOME/.local/bin/pipenv

pipenv installed using pip3 install pipenv --user

Expected behavior

Don't show a warning because it it clearly on my PATH

Steps to reproduce:

  1. pip3 install pipenv --user
  2. export PATH=$PATH:$HOME/.local/bin

Logs

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

No output shown

Output from Console under the Developer Tools panel (toggle Developer Tools on under Help)

No output shown

Activity

  1. MikhailArkhipov commented on Apr 7, 2018

    @MikhailArkhipov

    So if you run pipenv --venv from the workspace folder it does succeed?

  2. tristan957 commented on Apr 10, 2018

    @tristan957
    Author

    Yes the command succeeds

  3. DonJayamanne commented on Apr 10, 2018

    @DonJayamanne

    export PATH=$PATH:$HOME/.local/bin

    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?

  4. tristan957 commented on Apr 10, 2018

    @tristan957
    Author

    My bash profile is sourcing my bashrc where I am exporting the above path variable

  5. DonJayamanne commented on Apr 10, 2018

    @DonJayamanne

    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.

  6. tristan957 commented on Apr 10, 2018

    @tristan957
    Author

    I have restarted my computer within the last 3 days many times. I experienced this same issue a few hours ago.

  7. DonJayamanne commented on Apr 10, 2018

    @DonJayamanne

    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.

  8. tristan957 commented on Apr 10, 2018

    @tristan957
    Author

    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.

    image

  9. 47 remaining items

  10. dlukes commented on May 18, 2018

    @dlukes

    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).

  11. dlukes commented on May 22, 2018

    @dlukes

    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 :)

  12. brettcannon commented on May 23, 2018

    @brettcannon
    Member

    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.

  13. tristan957 commented on May 24, 2018

    @tristan957
    Author

    David Lukes (@dlukes) can you link the issue here when you open it in the vscode repo, or subscribe me to the issue?

  14. dlukes commented on May 25, 2018

    @dlukes

    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!

  15. DonJayamanne commented on Jun 14, 2018

    @DonJayamanne

    Modified to log the following env variables:

    • PATH
    • LC_ALL
    • LANG

    screen shot 2018-06-13 at 6 17 58 pm

  16. added a commit that references this issue on Jun 14, 2018
    a93ce84
  17. locked as resolved and limited conversation to collaborators on Jul 18, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    debtCode quality issues

    Type

    No type

    Projects

    No projects

      Milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions