Using poetry with GitPod

I am trying to setup my workspace (GitHub - kameshsampath/kameshsampath.demos: My Ansible Collections repository) and install python packages using poetry, but my setup is failing with the following error:

    gitpod /workspace/kameshsampath.demos $ poetry env use python
    Creating virtualenv kameshsampath.demos in /workspace/kameshsampath.demos/.venv
    Using virtualenv: /workspace/kameshsampath.demos/.venv
    gitpod /workspace/kameshsampath.demos $ poetry install 
    Installing dependencies from lock file

    Package operations: 73 installs, 0 updates, 0 removals

      • Installing pycparser (2.20): Failed

      EnvCommandError

      Command ['/workspace/kameshsampath.demos/.venv/bin/pip', 'install', '--no-deps', 'file:///home/gitpod/.cache/pypoetry/artifacts/f1/03/25/40eb46f7bede64f78ba073e2141b8216e611cbcde72e3117c326560101/pycparser-2.20-py2.py3-none-any.whl'] errored with the following return code 1, and output: 
      ERROR: Can not perform a '--user' install. User site-packages are not visible in this virtualenv.
      WARNING: You are using pip version 21.0.1; however, version 21.1 is available.
      You should consider upgrading via the '/workspace/kameshsampath.demos/.venv/bin/python -m pip install --upgrade pip' command.
      

      at ~/.poetry/lib/poetry/utils/env.py:1075 in _run
          1071│                 output = subprocess.check_output(
          1072│                     cmd, stderr=subprocess.STDOUT, **kwargs
          1073│                 )
          1074│         except CalledProcessError as e:
        → 1075│             raise EnvCommandError(e, input=input_)
          1076│ 
          1077│         return decode(output)
          1078│ 
          1079│     def execute(self, bin, *args, **kwargs):

    gitpod /workspace/kameshsampath.demos $ 

When I build the docker image locally and run the same commands as in my .gitpod.yml I see its working as expected.

Any thoughts ?

Hi @kameshsampath, welcome to the Gitpod community! :partying_face:

This --user error seems familiar… Could you please try the workaround suggested in this issue?

I am having the same issue even after setting PIP_USER=false. Is there any other workaround?

Creating virtualenv rl-trading-sU_mW-o9-py3.8 in /home/gitpod/.cache/pypoetry/virtualenvs
Installing dependencies from lock file

Package operations: 133 installs, 0 updates, 0 removals

  • Installing ipython-genutils (0.2.0): Failed

  EnvCommandError

  Command ['/home/gitpod/.cache/pypoetry/virtualenvs/rl-trading-sU_mW-o9-py3.8/bin/pip', 'install', '--no-deps', '/home/gitpod/.cache/pypoetry/artifacts/e6/8e/a3/8f37e14310c0072b3fcc4240490bcb42630aa695d069aee89953ebd9f8/ipython_genutils-0.2.0-py2.py3-none-any.whl'] errored with the following return code 1, and output: 
  ERROR: Can not perform a '--user' install. User site-packages are not visible in this virtualenv.
  WARNING: You are using pip version 21.1.3; however, version 21.2.1 is available.
  You should consider upgrading via the '/home/gitpod/.cache/pypoetry/virtualenvs/rl-trading-sU_mW-o9-py3.8/bin/python -m pip install --upgrade pip' command.
  

  at /opt/poetry/venv/lib/python3.8/site-packages/poetry/utils/env.py:1101 in _run
      1097│                 output = subprocess.check_output(
      1098│                     cmd, stderr=subprocess.STDOUT, **kwargs
      1099│                 )
      1100│         except CalledProcessError as e:
    → 1101│             raise EnvCommandError(e, input=input_)
      1102│ 
      1103│         return decode(output)
      1104│ 
      1105│     def execute(self, bin, *args, **kwargs):

I believe that this is related, worth looking into: Gitpod break the behavior of pre-commit of Python · Issue #4886 · gitpod-io/gitpod · GitHub

Happy Coding!