Skip to content
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

Can't use pyenv-virtualenv (ERROR: Can not perform a '--user' install) #1192

Open
LeSphax opened this issue Oct 3, 2023 · 1 comment
Open
Labels
bug Something isn't working team: team-experience Belonging to the Experience team

Comments

@LeSphax
Copy link

LeSphax commented Oct 3, 2023

Bug description

Our local setup uses pyenv-virtualenv to run mypy in a virtual environment with the same libraries as CI.

But using pyenv-virtualenv in gitpod results in the following error when doing pip install commands.

pip install -r python/picnic/requirements.txt 
ERROR: Can not perform a '--user' install. User site-packages are not visible in this virtualenv.

This is because the script /home/gitpod/.gp_pyenv.d/exec/gitpod.bash automatically sets PIP_USER=true in gitpod.

I'm not sure why this flag needs to be set but if it needs to be ideally there would be an error message to explain the reason when using a virtualenv.
Or at least a comment in the gitpod.bash script.

Right now I could change/remove that script in our docker image but I'm not sure what else would break if I did that.

Steps to reproduce

brew_upstall pyenv-virtualenv
pyenv virtualenv test
pyenv activate test
pip install openai

Expected behavior

No response

Example repository

This is our docker image in case it helps:

FROM gitpod/workspace-full:2022-11-06-15-53-10

RUN brew tap little-angry-clouds/homebrew-my-brews \
    && brew install \
        black \
        curl \
        helmenv \
        kubectl \
        mosh \
        mysql-client \
        nvm \
        tfenv \
        tgenv \
        tmux \
        fzf \
        bat \
        kubectx \
        exa \
        hstr \
        zoxide \
        stow \
        neovim

# Will install compatible dbt-core and dbt-extractor version as well
# The first install pass will give dependency resolver issue without erroring out
# The second install works as expected ¯\_(ツ)_/¯
RUN pip install dbt-bigquery==1.0.0 && pip install dbt-bigquery==1.0.0

USER root

# postgresql-client
RUN echo "deb http://apt.postgresql.org/pub/repos/apt $(lsb_release -cs)-pgdg main" > /etc/apt/sources.list.d/pgdg.list \
    && wget --quiet -O - https://www.postgresql.org/media/keys/ACCC4CF8.asc | apt-key add - \
    && apt-get update \
    && apt-get -y install postgresql-client-14

# gcloud
RUN echo "deb [signed-by=/usr/share/keyrings/cloud.google.gpg] https://packages.cloud.google.com/apt cloud-sdk main" | tee -a /etc/apt/sources.list.d/google-cloud-sdk.list \
    && curl https://packages.cloud.google.com/apt/doc/apt-key.gpg | apt-key --keyring /usr/share/keyrings/cloud.google.gpg add - \
    && apt-get update && apt-get install \
      google-cloud-cli \
      google-cloud-sdk-gke-gcloud-auth-plugin \
    && gcloud config set project local-184120 \
    && gcloud auth configure-docker gcr.io

# yq
ENV YQ_VERSION=v4.12.0
RUN curl -sSL https://github.com/mikefarah/yq/releases/download/${YQ_VERSION}/yq_linux_amd64 -o /usr/bin/yq \
    && chmod +x /usr/bin/yq \
    && yq --version

# shellcheck
ENV SHELLCHECK_VERSION=v0.7.1
RUN curl -sSL "https://github.com/koalaman/shellcheck/releases/download/${SHELLCHECK_VERSION}/shellcheck-${SHELLCHECK_VERSION}.linux.x86_64.tar.xz" | tar -xJf - \
    && mv "shellcheck-${SHELLCHECK_VERSION}/shellcheck" /usr/bin/ \
    && shellcheck --version

RUN apt-get -y install netcat
RUN rm /bin/sh && ln -s /bin/bash /bin/sh

USER gitpod

# Node.js
ENV NODE_VERSION=18.12.1
RUN . "$HOME/.nvm/nvm.sh" \
    && nvm install "$NODE_VERSION" \
    && nvm alias default node \
    && nvm use default \
    && node --version
ENV PATH="$HOME/.nvm/versions/node/v${NODE_VERSION}/bin:$PATH"

# Install Python from our .python-version
WORKDIR "$HOME/install_python"
COPY .python-version .
COPY infra/cloud/gitpod/tasks/install-python.sh .
RUN bash install-python.sh
RUN pyenv global "$(pyenv version-file-read .python-version)"
WORKDIR /

RUN sudo chown -R $USER ~
RUN mkdir -p /workspace/postgres/data /workspace/.config/gcloud
ENV DEV_LOCAL_IP=localhost
ENV PGHOST=localhost
ENV DOCKER_DB_HOST=postgres
ENV DOCKER_POSTGRES_VOLUME=/workspace/postgres/data:/workspace/postgres/data
ENV PATH="/workspace/picnic/bin:$PATH"
ENV TERRAGRUNT_DOWNLOAD=$HOME/.terragrunt-cache
RUN mkdir -p $TERRAGRUNT_DOWNLOAD

Anything else?

No response

@LeSphax LeSphax added the bug Something isn't working label Oct 3, 2023
@github-actions github-actions bot added the team: team-experience Belonging to the Experience team label Oct 3, 2023
@axonasif
Copy link
Member

axonasif commented Oct 5, 2023

Hi @LeSphax, can you try axonasif/workspace-python:debug2 as the base image? (context: #1071)


Also, wanted to share a few things about this part of the dockerfile (notice # <-- comments):

WORKDIR / # <-- does not affect Gitpod

RUN sudo chown -R $USER ~ # <-- not necessary, it is already set to gitpod:gitpod
RUN mkdir -p /workspace/postgres/data /workspace/.config/gcloud # <-- will not work, see https://www.gitpod.io/docs/configure/workspaces/workspace-lifecycle#workspace-statuses  |  you could take reference from https://github.com/gitpod-io/workspace-images/tree/main/chunks/tool-postgresql
ENV DEV_LOCAL_IP=localhost
ENV PGHOST=localhost
ENV DOCKER_DB_HOST=postgres
ENV DOCKER_POSTGRES_VOLUME=/workspace/postgres/data:/workspace/postgres/data
ENV PATH="/workspace/picnic/bin:$PATH"
ENV TERRAGRUNT_DOWNLOAD=$HOME/.terragrunt-cache
RUN mkdir -p $TERRAGRUNT_DOWNLOAD

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working team: team-experience Belonging to the Experience team
Projects
None yet
Development

No branches or pull requests

2 participants