jumanjihouse / pre-commit-hooks

git pre-commit hooks that work with http://pre-commit.com/
MIT License
114 stars 52 forks source link

pre-commit fails with Alpine 3.15 #99

Open krish7919 opened 2 years ago

krish7919 commented 2 years ago

We were using Alpine 3.13 so far and upgrading to Alping 3.15 got in an upgrade of ruby to v3.0.3-r0, among other things.

I install ruby in my image:

...
        ruby=3.0.3-r0 \
        ruby-dev=3.0.3-r0 \
...

And then install pre-commit with version pre-commit==2.17.0.

However after all this, pre-commit install in my container fails with:

[INFO] Installing environment for https://github.com/jumanjihouse/pre-commit-hooks.
[INFO] Once installed this environment will be reused.
[INFO] This may take a few minutes...
An unexpected error has occurred: CalledProcessError: command: ('/usr/bin/ruby', '/usr/bin/gem', 'install', '--no-document', '--no-format-executable', 'fake_gem__-0.0.0.gem')
return code: 1
expected return code: 0
stdout: (none)
stderr:
    ERROR:  While executing gem ... (Gem::DependencyResolutionError)
        conflicting dependencies rubocop (>= 0.71.0) and rubocop (= 1.10.0)
      Activated rubocop-1.10.0
      which does not match conflicting dependency (>= 0.71.0)

      Conflicting dependency chains:
        fake_gem__ (= 0.0.0), 0.0.0 activated, depends on
        rubocop (= 1.10.0), 1.10.0 activated

      versus:
        fake_gem__ (= 0.0.0), 0.0.0 activated, depends on
        rubocop-performance (= 1.6.1), 1.6.1 activated, depends on
        rubocop (>= 0.71.0)

Check the log at /root/.cache/pre-commit/pre-commit.log

The log file has:

### version information
pre-commit version: 2.17.0
git --version: git version 2.34.1
sys.version:
    3.9.7 (default, Nov 24 2021, 21:15:59) 
    [GCC 10.3.1 20211027]
sys.executable: /usr/bin/python3
os.name: posix
sys.platform: linux

### error information

An unexpected error has occurred: CalledProcessError: command: ('/usr/bin/ruby', '/usr/bin/gem', 'install', '--no-document', '--no-format-executable', 'fake_gem__-0.0.0.gem')
return code: 1
expected return code: 0
stdout: (none)
stderr:
    ERROR:  While executing gem ... (Gem::DependencyResolutionError)
        conflicting dependencies rubocop (>= 0.71.0) and rubocop (= 1.10.0)
      Activated rubocop-1.10.0
      which does not match conflicting dependency (>= 0.71.0)

      Conflicting dependency chains:
        fake_gem__ (= 0.0.0), 0.0.0 activated, depends on
        rubocop (= 1.10.0), 1.10.0 activated

      versus:
        fake_gem__ (= 0.0.0), 0.0.0 activated, depends on
        rubocop-performance (= 1.6.1), 1.6.1 activated, depends on
        rubocop (>= 0.71.0)

Traceback (most recent call last):
  File "/usr/lib/python3.9/site-packages/pre_commit/error_handler.py", line 70, in error_handler
    yield
  File "/usr/lib/python3.9/site-packages/pre_commit/main.py", line 396, in main
    return run(args.config, store, args)
  File "/usr/lib/python3.9/site-packages/pre_commit/commands/run.py", line 416, in run
    install_hook_envs(to_install, store)
  File "/usr/lib/python3.9/site-packages/pre_commit/repository.py", line 224, in install_hook_envs
    _hook_install(hook)
  File "/usr/lib/python3.9/site-packages/pre_commit/repository.py", line 82, in _hook_install
    lang.install_environment(
  File "/usr/lib/python3.9/site-packages/pre_commit/languages/ruby.py", line 135, in install_environment
    helpers.run_setup_cmd(
  File "/usr/lib/python3.9/site-packages/pre_commit/languages/helpers.py", line 52, in run_setup_cmd
    cmd_output_b(*cmd, cwd=prefix.prefix_dir, **kwargs)
  File "/usr/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: ('/usr/bin/ruby', '/usr/bin/gem', 'install', '--no-document', '--no-format-executable', 'fake_gem__-0.0.0.gem')
return code: 1
expected return code: 0
stdout: (none)
stderr:
    ERROR:  While executing gem ... (Gem::DependencyResolutionError)
        conflicting dependencies rubocop (>= 0.71.0) and rubocop (= 1.10.0)
      Activated rubocop-1.10.0
      which does not match conflicting dependency (>= 0.71.0)

      Conflicting dependency chains:
        fake_gem__ (= 0.0.0), 0.0.0 activated, depends on
        rubocop (= 1.10.0), 1.10.0 activated

      versus:
        fake_gem__ (= 0.0.0), 0.0.0 activated, depends on
        rubocop-performance (= 1.6.1), 1.6.1 activated, depends on
        rubocop (>= 0.71.0)

I have tried downgrading virtualenv to 20.0.33 (but I do not know how this is related), and there has been no change.

Has anyone made pre-commit work with the latest Alpine 3.15 stable image?

Xartos commented 2 years ago

I'm getting the same error on Ubuntu 22.04

$ pre-commit install --install-hooks
pre-commit installed at .git/hooks/pre-commit
[INFO] Installing environment for https://github.com/jumanjihouse/pre-commit-hooks.
[INFO] Once installed this environment will be reused.
[INFO] This may take a few minutes...
An unexpected error has occurred: CalledProcessError: command: ('/usr/bin/ruby', '/usr/bin/gem', 'install', '--no-document', '--no-format-executable', 'fake_gem__-0.0.0.gem')
return code: 1
expected return code: 0
stdout: (none)
stderr:
    ERROR:  While executing gem ... (Gem::DependencyResolutionError)
        conflicting dependencies rubocop (>= 0.71.0) and rubocop (= 0.85.1)
      Activated rubocop-0.85.1
      which does not match conflicting dependency (>= 0.71.0)

      Conflicting dependency chains:
        fake_gem__ (= 0.0.0), 0.0.0 activated, depends on
        rubocop (= 0.85.1), 0.85.1 activated

      versus:
        fake_gem__ (= 0.0.0), 0.0.0 activated, depends on
        rubocop-performance (= 1.6.1), 1.6.1 activated, depends on
        rubocop (>= 0.71.0)

$ pre-commit --version
pre-commit 2.17.0
andthum commented 2 years ago

I'm experiencing the same error. Seems to be related to #89. Are there any updates on this?