-
Notifications
You must be signed in to change notification settings - Fork 1.3k
Gitpod break the behavior of pre-commit of Python #4886
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
Sounds like we should not be setting |
Really yes, the team of |
Hello everybody! I'm facing a similar (maybe even the exact same, but I'm not quite sure as I'm pretty new to Gitpod 😄) issue. Given the following FROM gitpod/workspace-full
SHELL ["/bin/bash", "-o", "pipefail", "-c"]
ENV PATH="${HOME}/.poetry/bin:${PATH}"
ENV PIP_USER="no"
RUN curl -sSL https://raw.githubusercontent.com/python-poetry/poetry/master/get-poetry.py | python3 - \
&& poetry config virtualenvs.create "true" \
&& poetry config virtualenvs.in-project "true"
|
Should be great that .bashrc was generated getting the environment @billsioros this was my solution FROM gitpod/workspace-postgres
RUN sudo apt-get update \
&& sudo apt-get update \
&& sudo apt-get install -y redis-server \
&& sudo apt-get clean \
&& sudo rm -rf /var/cache/apt/* /var/lib/apt/lists/* /tmp/*
RUN pyenv update && pyenv install 3.9.6 && pyenv global 3.9.6
RUN pip install pipenv
# remove PIP_USER environment
USER gitpod
RUN if ! grep -q "export PIP_USER=no" "$HOME/.bashrc"; then printf '%s\n' "export PIP_USER=no" >> "$HOME/.bashrc"; fi |
Hi @jefer94, thank you very much! Sadly my issue has not been resolved. Shouldn't Edit: I'm not quite sure, but could it be due to spawning a python virtual environment and afterwards installing the dependencies? |
@billsioros no necesaryly, you have the |
Hello again @jefer94. If I'm correct, Gitpod does not proceed to execute commands specified by tasks if a new shell is instantiated. But should this be considered an issue? I'm not sure about any security complications it might introduce, but I think something like this should be at least documented (I'm sorry if it is already documented, I search for information on the matter but couldn't come up with anything 😢) |
In Gitpod I think is not necesary use virtualenv, but for you resolve you issue you need to set the |
This is an issue with workspace-full itself. I've raised a PR in workspace-images to set |
Isn't this rather an issue with the gitpod-layer? gitpod/components/image-builder/workspace-image-layer/gitpod-layer/debian/gitpod/.bashrc-prepend Lines 39 to 44 in af51739
|
@billsioros I got that problem fixed in a hacky way by setting env vars in files under # ────────────────────────────────────────────────────────────────────────────────
USER root
ENV EDITOR="nvim"
ENV VISUAL="nvim"
ENV PATH="${PATH}:/usr/local/bin"
WORKDIR "/etc/profile.d"
RUN \
[ -d "${HOME}/.bashrc.d" ] && while read i; do ln -sf "$i" "/etc/profile.d/$(basename $i).sh"; done < <(find ${HOME}/.bashrc.d -type f ) || true ; \
curl \
-fsSl https://raw.githubusercontent.com/3hhh/fzfuncs/master/bashrc_fzf \
-o /etc/profile.d/bashrc_fzf.sh \
&& ( \
echo "export EDITOR=\"${EDITOR}\"" ; \
echo "export VISUAL=\"${VISUAL}\"" ; \
echo 'export DOCKER_BUILDKIT="0"' ; \
echo 'export BUILDKIT_PROGRESS="auto"' ; \
echo 'export COMPOSE_DOCKER_CLI_BUILD="0"' ; \
echo 'export GEM_HOME=/workspace/.rvm' ; \
echo 'export GEM_PATH=$GEM_HOME:$GEM_PATH' ; \
echo 'export GOROOT="${HOME}/go" ;' ; \
echo 'export GOPATH="/workspace/go-packages" ;' ; \
echo 'export PYTHONUSERBASE=/workspace/.pip-modules ;' ; \
echo 'export PATH="${PATH}:/usr/local/bin"' ; \
echo '[ -d ${GEM_HOME} ] && export PATH="${GEM_HOME}/bin:$PATH" ;' ; \
echo '[ -d ${GOROOT} ] && export PATH="${GO_ROOT}/bin:$PATH" ;' ; \
echo '[ -d ${GOPATH} ] && export PATH="${GOPATH}/bin:$PATH" ;' ; \
echo '[ -d ${HOME}/.local/bin ] && export PATH="${HOME}/.local/bin:${PATH}"' ; \
echo '[ -d ${HOME}/.cargo/bin ] && export PATH="${HOME}/.cargo/bin:${PATH}";'; \
echo '[ -d ${PYTHONUSERBASE} ] && export PATH="${PYTHONUSERBASE}/bin:$PATH" ;' ; \
echo '[ -d ${HOME}/.pyenv/bin ] && export PATH="${HOME}/.pyenv/bin:${PATH}";' ; \
echo '[ -d ${HOME}/.pyenv/shims ] && export PATH="${HOME}/.pyenv/shims:${PATH}" ;' ; \
echo '[ -d ${HOME}/bin ] && export PATH="${HOME}/bin":${PATH}' ; \
echo 'npm --version >/dev/null 2>&1 && export PATH="$(npm -g bin):${PATH}" ;' ; \
echo 'yarn --version >/dev/null 2>&1 && export PATH="$(yarn global bin):${PATH}" ;' ; \
echo 'gp --help >/dev/null 2>&1 && (eval $(gp env | sed -e "s/\(=[[:blank:]]*\)\(.*\)/\1\"\2\" ;/" -e "s/^/export /g") ; source <(gp completion) ;)' ; \
echo 'starship --version >/dev/null 2>&1 && eval "$(starship init bash)" ;' ; \
echo 'just --version >/dev/null 2>&1 && eval "$(just --completions bash)" ;' ; \
echo 'rustup --version >/dev/null 2>&1 && eval "$(rustup completions bash rustup)" && eval "$(rustup completions bash cargo)";' ; \
echo 'curl --version >/dev/null 2>&1 && source <(curl -sSL git.io/forgit) ;' ; \
) | tee 00-env.sh > /dev/null \
&& ( \
echo "alias apt='sudo apt'" ; \
echo "alias g='git'" ; \
echo 'exa --version >/dev/null 2>&1 && alias la="exa -A";alias ll="exa -alhF";alias ls="exa";' ; \
echo 'bat --version >/dev/null 2>&1 && alias cat="bat -pp";' ; \
echo 'just --version >/dev/null 2>&1 && alias j="just";' ; \
echo "alias nvim='nvim --headless -c \"call dein#recache_runtimepath()\" -c \"qall\" && nvim'" ; \
) | tee 01-alias.sh > /dev/null \
&& ( \
echo '(rg -h >/dev/null 2>&1 && bat -h >/dev/null 2>&1 && sk -h >/dev/null 2>&1 ) && function fp { rg --files $1 | sk --preview="bat {} --color=always --style=grid,numbers" ; }' ; \
echo '(rg -h >/dev/null 2>&1 && sk -h >/dev/null 2>&1 ) && function fs { sk -i -c "rg {} --color=always $1" --ansi ; }' ; \
) | tee 02-func.sh > /dev/null \
&& [ -r /etc/bash.bashrc ] && (\
echo 'while read i; do source "$i"; done < <(find /etc/profile.d/ -name "*.sh") ;' ; \
) | tee -a /etc/bash.bashrc
# ────────────────────────────────────────────────────────────────────────────────
USER gitpod
WORKDIR "${HOME}"
RUN \
[ -r "${HOME}/.bashrc.d/60-python" ] \
&& sed -i -e 's/pyenv/${HOME}\/.pyenv\/bin\/pyenv/g' "${HOME}/.bashrc.d/60-python" \
&& sed -i \
-e '/\$HOME\/\.bashrc\.d/d' \
-e '/PIP/d' \
-e '/PYTHONUSERBASE/d' \
-e '/gp completion/d' \
-e '/\.cargo\/env/d' \
-e '/rvm/d' \
-e '/GEM/d' \
"${HOME}/.bashrc" \
&& ( \
echo "[ -r '\${HOME}/.bashrc' ] && sed -i \\" ; \
echo "-e '/\\\$HOME\/\.bashrc\.d/d' \\" ; \
echo "-e '/cargo/d' \\" ; \
echo "-e '/PIP/d' \\" ; \
echo "-e '/PYTHONUSERBASE/d' \\" ; \
echo "-e '/gp completion/d' \\" ; \
echo "-e '/rvm/d' \\" ; \
echo "-e '/GEM/d' \\" ; \
echo "'\${HOME}/.bashrc' \\" ; \
echo '&& . ${HOME}/.bashrc' ; \
) | tee "${HOME}/.profile" > /dev/null ;
# ──────────────────────────────────────────────────────────────────────────────── there are more steps involved so I would recommend you to study my Gitpod docker image here. To test and see if your repo and local config works with my changes, you can open my |
Hello @da-moon, I have already adopted the workaround described by @jefer94, but I appreciate the advice! Thanks very much 😄
|
I see this was closed a few months ago, but I just hit this issue. Has the fix been released yet? In case it helps anyone else, I am working around this for now by prepending |
Have been ablet to reproduce this problem in workspace-images/
|
I think that's not the right approach set |
Came here to say that apparently this has been fixed in the latest Gitpod version -- I've just launched a project managed by Poetry + pre-commit that didn't work before.... and setup worked in the first try. env | grep "PIP"
PIPENV_VENV_IN_PROJECT=true
PIP_USER=no |
Awesome, thanks for verifying. |
I just tried removing the
from the GitPod Are you sure this is fixed? |
I tried with a repo without a Run |
@svenefftinge, when you have a moment, could you please take a peek at https://gitpod.io/#https://github.com/jab/bidict/pull/238 (which shows that when I remove the workaround for this issue I get the |
I can reopen the issue, of course. We could certainly need some help from Python experts to figure out what's going on here. |
Thanks! |
@jab Maybe it has something to do with this issue. |
Thanks @utam0k, I noticed that $PATH bug too! But it looks like I'm hitting something far weirder. Just left a comment in gitpod-io/workspace-images#664 (comment) in case anyone has any ideas. Thank you! |
Thanks for your response. I'll check these comments. |
@jab I will close this issue in order to consolidate the issues. gitpod-io/workspace-images#664 If you still have any questions, please reopen this issue or create a new issue. @svenefftinge |
Bug description
Steps to reproduce
Select a workspace with Django, install pipenv, install pre-commit, do anything that use pre-commit
Expected behavior
That pre-commit run in Gitpod without modify the
.bashrc
also is common break the docker image if we trying to mount other.bashrc
Example repository
No response
Anything else?
Here is my solution pre-commit/pre-commit#1985
The text was updated successfully, but these errors were encountered: