Skip to content

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

Open
@LeSphax

Description

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

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't workingteam: team-experienceBelonging to the Experience team

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions