-
Notifications
You must be signed in to change notification settings - Fork 327
Incorrect $PATH
affecting many executables (including python3)
#664
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
Comments
As an example, users are working around path and other issues like so -https://github.com/couchbase-examples/python-quickstart/pull/4/files |
The reason why
But then, after entering the workspace, take the workspace-full-vnc as an example, the PATH becomes,
This is after deduplication, there are actually many duplicates. Anyway, as seen from the result, the following paths now precedence the /home/gitpod/.pyenv/shims path, which is how pyenv works.
I would suggest not setting it in the Dockerfile, instead, we can set it in the /home/gitpod/.bashrc.d/60-python script (which I tested, works for python). Besides, this can be easily done calling the pyenv generated script I think this will not break other tools in the workspace. As the added path only hook commands are related to python, which is why pyenv is used in the first place. If the gitpod team think this is ok, I can submit a PR. |
besides, I think this is due to how dazzle merges the PATH variables. It seems that dazzle neither preserves the order in the PATH nor remove duplicates in the PATH. [there are duplicates even in the workspace-base image] |
@huweiATgithub @samirotiv (cc @Furisto @kylos101 ) |
I see the related PR has been merged but in a fresh workspace-full image, the order in PATH is still not correct,
|
@huweiATgithub Thanks for your checking. But we haven't released a new image which is included fixing this problem yet. The last update was 7 days ago in dockerhub and a PR to fix this problem was merged 3 days ago. Please wait until the next release. If you want to fix this issue in a hurry, you can commit like this. |
Specifically, you can see in https://github.com/jab/bidict/blob/09c1705973dd75c95e7771cdca5b4f3ebac3c4b5/.gitpod.yml#L20-L27 tasks:
- init: |
eval "$(pyenv init --path)" # https://github.com/gitpod-io/workspace-images/issues/664#issuecomment-1054827300
pyenv install 3.10.2
pyenv global 3.10.2
pip install -U pip
pip install -r requirements/dev.txt And the console output includes, for example, the following:
Note that "setuptools" was found in the path /home/gitpod/.pyenv/versions/3.10.2. This shows that pyenv successfully installed python 3.10.2, the "python" command now resolves to that version (rather than the system version 3.8), and "pip" resolves to the pip executable installed for that version of python, rather than /usr/bin/pip corresponding to the system python. But if you load https://gitpod.io/#https://github.com/jab/bidict and then try to actually use the environment, it's as if none of the stuff in the gitpod /workspace/bidict (main) $ pyenv versions
system
* 3.8.12 (set by /home/gitpod/.pyenv/version)
gitpod /workspace/bidict (main) $ ls /home/gitpod/.pyenv/versions
3.8.12
gitpod /workspace/bidict (main) $ which pip
/usr/bin/pip
gitpod /workspace/bidict (main) $ pip -V
pip 20.0.2 from /usr/lib/python3/dist-packages/pip (python 3.8) At this point I've burned many hours trying to figure out what's going on with GitPod here, so any help from the community would be greatly appreciated! |
@jab That calling eval "$(pyenv init --path)" will append pyenv's path into PATH and only affect the current shell. For a workaround, you may also want to echo that into the /home/gitpod/.bashrc.d/60-python so that it is being invoked for every shell. |
Thanks, @huweiATgithub, I appreciate your trying to help. I tried your suggestion though and unfortunately it doesn't help. If you open https://gitpod.io/#https://github.com/jab/bidict and run gitpod /workspace/bidict (main) $ HISTFILE=/workspace/.gitpod/cmd-0 history -r; {
> echo 'eval "$(pyenv init --path)"' >> ~/.bashrc.d/60-python # https://github.com/gitpod-io/workspace-images/issues/664
> bash -l
> pyenv install 3.10.2
> pyenv global 3.10.2
> pip -V | fgrep 'python 3.10' # 'pip' should resolve to ~/.pyenv/versions/3.10.2/lib/python3.10/site-packages/pip
> pip install -U pip
> pip install -r requirements/dev.txt
> pre-commit install --install-hooks
>
> }
gitpod /workspace/bidict (main) $ cat ~/.bashrc.d/60-python # implements your suggestion
eval "$(pyenv init -)"
eval "$(pyenv virtualenv-init -)"
eval "$(pyenv init --path)"
gitpod /workspace/bidict (main) $ pyenv versions # `pyenv install 3.10.2` never happened?
system
* 3.8.12 (set by /home/gitpod/.pyenv/version) Any other suggestions? At this point it really feels like GitPod is gaslighting me. 🥴 Really hope a GitPod community or team member can help! |
Wow, I think compressing my - init: echo 'eval "$(pyenv init --path)"' >> ~/.bashrc.d/60-python `# https://github.com/gitpod-io/workspace-images/issues/664` && eval $(pyenv init --path) && pyenv install 3.10.2 && pyenv global 3.10.2 && pip -V | fgrep 'python 3.10' && pip install -U pip && pip install -r requirements/dev.txt && pre-commit install --install-hooks
|
@jab I think the single line is not the key. |
$PATH
affecting many executables (including python3)
@jab LGTM. I've changed the title of this issue.
|
Maybe yes. Anyway, you need to override the
But as for the code base, this problem has been solved. gitpod-io/dazzle#43 However, it has not been released yet. In other words, It has been fixed, but not yet delivered to the user. |
Thanks for your suggestion. I think we don't need to do it because this problem will soon be fixed.
|
@huweiATgithub tasks:
- init: |
echo 'eval "$(pyenv init --path)"' >> ~/.bashrc.d/60-python
eval "$(pyenv init --path)" # https://github.com/gitpod-io/workspace-images/issues/664#issuecomment-1054827300
pyenv install 3.10.2
pyenv global 3.10.2
pip install -U pip
pip install -r requirements/dev.txt |
Thank you @utam0k and @huweiATgithub, @utam0k's suggestion in the previous comment works! Notice the only difference between that and what I already tried in #664 (comment) is, after appending the eval line to The main problem I'm having now though is, even though we got my And even though the https://www.gitpod.io/docs/languages/python#python-versions docs explain that you can use pyenv to install a different Python version, they don't say anything about how to get VS Code to actually use it. Worse, if a user who wants to contribute to my project clicks my "edit in GitPod" link and then somehow actually notices they need to change VS Code to a different Python version, when they try to, the intended version Python 3.10.2 is not a directly available option (neither via ~/.pyenv/versions/3.10.2 nor via ~/.pyenv/shims/python): So they have to somehow know to manually type in ~/.pyenv/shims/python to get the right version of Python: Any ideas? |
@jab I came up with another solution for PATH. Can you use this image until a new one is released? This one is before the new dazzle and does not contain the PATH issue. |
@jab Thanks for reporting the problem with the python version in vscode. But perhaps it would be good to speak on a different issue. @axonasif @pawlean Can I ask you to handle this issue? Shall I create an issue in gitpod-io/gitpod? |
@jab @samirotiv @huweiATgithub Sorry for the confusion about the name of the image tag, but carefully that the tag I used in the commit above is newer than |
@utam0k That tag you mentioned works! Thank you. Hope the latest tag will get that fix soon. @jab you may try to reload your vscode (close and re-open the window, don't close the entire workspace). The stuff in init is running with the launching of vscode I guess (as you can see the terminal that runs init commands in the opened workspace). I tested, after reloading vscode, it can discover the newly installed python interpreter.
|
Hi @samirotiv and @huweiATgithub , Should be all set now. Have a nice weekend! Status: Downloaded newer image for gitpod/workspace-python:latest
gitpod ~ $ which python
/home/gitpod/.pyenv/shims/python
gitpod ~ $ which python3
/home/gitpod/.pyenv/shims/python3 |
Thanks, everyone. @utam0k wrote:
Looks like no one did this yet, so I just opened gitpod-io/gitpod#8646 |
@jab Thank you for opening new issue 👍 |
I re-open this issue, as in the latest full image (e249a43d75e6), the path is still in a mess, i.e. it is in the wrong order, and it contains many duplicates. |
@huweiATgithub Thanks for your report. Please let me organize the problem you pointed out. What order do you expect and what is the actual order regarding
|
@huweiATgithub may we ask you to pen a new issue, describing the problem with |
Bug description
Both
python
andpython3
need to come from pyenv. Currentlypython
comes from pyenv butpython3
comes from/bin
- the in-built python.Steps to reproduce
Expected behavior
Example repository
Just run the code sample above, anywhere.
Anything else?
$PATH
seems to be getting overridden in some build step.The text was updated successfully, but these errors were encountered: