Skip to content

Gitpod break the behavior of pre-commit of Python #4886

Closed
gitpod-io/workspace-images
#461
@jefer94

Description

@jefer94

Bug description

[INFO] Restored changes from /home/gitpod/.cache/pre-commit/patch1626779319-12649.
An unexpected error has occurred: CalledProcessError: command: ('/home/gitpod/.cache/pre-commit/reponkw94t64/py_env-python3.9/bin/python', '-mpip', 'install', '.')
return code: 1
expected return code: 0
stdout: (none)
stderr:
    ERROR: Can not perform a '--user' install. User site-packages are not visible in this virtualenv.
    
Check the log at /home/gitpod/.cache/pre-commit/pre-commit.log
version information

pre-commit version: 2.13.0
sys.version:
    3.9.6 (default, Jul  3 2021, 16:40:50) 
    [GCC 9.3.0]
sys.executable: /workspace/apiv2/.venv/bin/python
os.name: posix
sys.platform: linux

### error information

An unexpected error has occurred: CalledProcessError: command: ('/home/gitpod/.cache/pre-commit/reponkw94t64/py_env-python3.9/bin/python', '-mpip', 'install', '.')
return code: 1
expected return code: 0
stdout: (none)
stderr:
    ERROR: Can not perform a '--user' install. User site-packages are not visible in this virtualenv.
    
Traceback (most recent call last):
  File "/workspace/apiv2/.venv/lib/python3.9/site-packages/pre_commit/error_handler.py", line 65, in error_handler
    yield
  File "/workspace/apiv2/.venv/lib/python3.9/site-packages/pre_commit/main.py", line 385, in main
    return run(args.config, store, args)
  File "/workspace/apiv2/.venv/lib/python3.9/site-packages/pre_commit/commands/run.py", line 408, in run
    install_hook_envs(to_install, store)
  File "/workspace/apiv2/.venv/lib/python3.9/site-packages/pre_commit/repository.py", line 224, in install_hook_envs
    _hook_install(hook)
  File "/workspace/apiv2/.venv/lib/python3.9/site-packages/pre_commit/repository.py", line 82, in _hook_install
    lang.install_environment(
  File "/workspace/apiv2/.venv/lib/python3.9/site-packages/pre_commit/languages/python.py", line 204, in install_environment
    helpers.run_setup_cmd(prefix, install_cmd)
  File "/workspace/apiv2/.venv/lib/python3.9/site-packages/pre_commit/languages/helpers.py", line 52, in run_setup_cmd
    cmd_output_b(*cmd, cwd=prefix.prefix_dir)
  File "/workspace/apiv2/.venv/lib/python3.9/site-packages/pre_commit/util.py", line 154, in cmd_output_b
    raise CalledProcessError(returncode, cmd, retcode, stdout_b, stderr_b)
pre_commit.util.CalledProcessError: command: ('/home/gitpod/.cache/pre-commit/reponkw94t64/py_env-python3.9/bin/python', '-mpip', 'install', '.')
return code: 1
expected return code: 0
stdout: (none)
stderr:
    ERROR: Can not perform a '--user' install. User site-packages are not visible in this virtualenv.

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

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions