alessandrojcm / commitlint-pre-commit-hook

A pre-commit hook for commitlint
MIT License
151 stars 17 forks source link

Error installing v9.3.0 #98

Closed adam-moss closed 1 year ago

adam-moss commented 1 year ago

Pre-Commit surfacing an npm error when trying to install v9.3.0

[INFO] Installing environment for https://github.com/alessandrojcm/commitlint-pre-commit-hook.
[INFO] Once installed this environment will be reused.
[INFO] This may take a few minutes...
An unexpected error has occurred: CalledProcessError: command: ('/Users/adam.moss/.cache/pre-commit/repoz7s9m9oo/node_env-default/bin/node', '/Users/adam.moss/.cache/pre-commit/repoz7s9m9oo/node_env-default/bin/npm', 'install', '-g', '/Users/adam.moss/.cache/pre-commit/repoz7s9m9oo/commitlint-pre-commit-hook-1.0.0.tgz', '@commitlint/config-conventional')
return code: 1
expected return code: 0
stdout: (none)
stderr:
    npm ERR! code ETARGET
    npm ERR! notarget No matching version found for @commitlint/resolve-extends@^17.3.0.

Minimal .pre-commit-config.yaml

%YAML 1.2
# yaml-language-server: $schema=https://json.schemastore.org/pre-commit-config.json
---
default_install_hook_types:
    - pre-commit
    - commit-msg

default_stages:
    - commit

fail_fast: true

repos:
    - repo: https://github.com/alessandrojcm/commitlint-pre-commit-hook
      rev: v9.3.0
      hooks:
          - id: commitlint
            stages:
                - commit-msg
            additional_dependencies:
                - "@commitlint/config-conventional"
alessandrojcm commented 1 year ago

Hm, it does work for me here. Anyway, you're missing the commitlint.config.js file; could you add this file to the root of your repo please:

//comitling.config.js at the root of your repo
module.exports = {
  extends: ['@commitlint/config-conventional'], // => commitlint/config-conventional
};

And then add this bit after the additional_dependencies in the pre-commit config file:

args: ['--config','./commitlint.config.js']

And tell me if it works?

adam-moss commented 1 year ago

Same issue I'm afraid, although 17.3.0 does seem to exist on npm 🤔 :

~/Projects/personal/temp (main *+%) % pre-commit clean
Cleaned /Users/adam.moss/.cache/pre-commit.
~/Projects/personal/temp (main *+%) % pre-commit install --install-hooks
pre-commit installed at .git/hooks/pre-commit
pre-commit installed at .git/hooks/commit-msg
pre-commit installed at .git/hooks/post-commit
[INFO] Initializing environment for https://github.com/alessandrojcm/commitlint-pre-commit-hook.
[INFO] Initializing environment for https://github.com/alessandrojcm/commitlint-pre-commit-hook:@commitlint/config-conventional.
[INFO] Installing environment for https://github.com/alessandrojcm/commitlint-pre-commit-hook.
[INFO] Once installed this environment will be reused.
[INFO] This may take a few minutes...
 An unexpected error has occurred: CalledProcessError: command: ('/Users/adam.moss/.cache/pre-commit/repo0b_3uta1/node_env-default/bin/node', '/Users/adam.moss/.cache/pre-commit/repo0b_3uta1/node_env-default/bin/npm', 'install', '-g', '/Users/adam.moss/.cache/pre-commit/repo0b_3uta1/commitlint-pre-commit-hook-1.0.0.tgz', '@commitlint/config-conventional')
return code: 1
expected return code: 0
stdout: (none)
stderr:
    npm ERR! code ETARGET
    npm ERR! notarget No matching version found for @commitlint/resolve-extends@^17.3.0.
    npm ERR! notarget In most cases you or one of your dependencies are requesting
    npm ERR! notarget a package version that doesn't exist.

    npm ERR! A complete log of this run can be found in:
    npm ERR!     /Users/adam.moss/.npm/_logs/2022-11-24T13_35_27_856Z-debug-0.log

Check the log at /Users/adam.moss/.cache/pre-commit/pre-commit.log
~/Projects/personal/temp (main *+%) %

pre-commit.log

### version information

pre-commit version: 2.20.0 git --version: git version 2.38.1 sys.version: 3.11.0 (main, Nov 8 2022, 10:36:15) [Clang 14.0.0 (clang-1400.0.29.202)] sys.executable: /Users/adam.moss/.homebrew/Cellar/pre-commit/2.20.0_1/libexec/bin/python3.11 os.name: posix sys.platform: darwin


### error information

An unexpected error has occurred: CalledProcessError: command: ('/Users/adam.moss/.cache/pre-commit/repo0b_3uta1/node_env-default/bin/node', '/Users/adam.moss/.cache/pre-commit/repo0b_3uta1/node_env-default/bin/npm', 'install', '-g', '/Users/adam.moss/.cache/pre-commit/repo0b_3uta1/commitlint-pre-commit-hook-1.0.0.tgz', '@commitlint/config-conventional') return code: 1 expected return code: 0 stdout: (none) stderr: npm ERR! code ETARGET npm ERR! notarget No matching version found for @commitlint/resolve-extends@^17.3.0. npm ERR! notarget In most cases you or one of your dependencies are requesting npm ERR! notarget a package version that doesn't exist.

npm ERR! A complete log of this run can be found in:
npm ERR!     /Users/adam.moss/.npm/_logs/2022-11-24T13_35_27_856Z-debug-0.log

Traceback (most recent call last): File "/Users/adam.moss/.homebrew/Cellar/pre-commit/2.20.0_1/libexec/lib/python3.11/site-packages/pre_commit/error_handler.py", line 73, in error_handler yield File "/Users/adam.moss/.homebrew/Cellar/pre-commit/2.20.0_1/libexec/lib/python3.11/site-packages/pre_commit/main.py", line 368, in main return install( ^^^^^^^^ File "/Users/adam.moss/.homebrew/Cellar/pre-commit/2.20.0_1/libexec/lib/python3.11/site-packages/pre_commit/commands/install_uninstall.py", line 140, in install install_hooks(config_file, store) File "/Users/adam.moss/.homebrew/Cellar/pre-commit/2.20.0_1/libexec/lib/python3.11/site-packages/pre_commit/commands/install_uninstall.py", line 146, in install_hooks install_hook_envs(all_hooks(load_config(config_file), store), store) File "/Users/adam.moss/.homebrew/Cellar/pre-commit/2.20.0_1/libexec/lib/python3.11/site-packages/pre_commit/repository.py", line 223, in install_hook_envs _hook_install(hook) File "/Users/adam.moss/.homebrew/Cellar/pre-commit/2.20.0_1/libexec/lib/python3.11/site-packages/pre_commit/repository.py", line 79, in _hook_install lang.install_environment( File "/Users/adam.moss/.homebrew/Cellar/pre-commit/2.20.0_1/libexec/lib/python3.11/site-packages/pre_commit/languages/node.py", line 117, in install_environment helpers.run_setup_cmd(prefix, install) File "/Users/adam.moss/.homebrew/Cellar/pre-commit/2.20.0_1/libexec/lib/python3.11/site-packages/pre_commit/languages/helpers.py", line 48, in run_setup_cmd cmd_output_b(*cmd, cwd=prefix.prefix_dir, **kwargs) File "/Users/adam.moss/.homebrew/Cellar/pre-commit/2.20.0_1/libexec/lib/python3.11/site-packages/pre_commit/util.py", line 146, in cmd_output_b raise CalledProcessError(returncode, cmd, retcode, stdout_b, stderr_b) pre_commit.util.CalledProcessError: command: ('/Users/adam.moss/.cache/pre-commit/repo0b_3uta1/node_env-default/bin/node', '/Users/adam.moss/.cache/pre-commit/repo0b_3uta1/node_env-default/bin/npm', 'install', '-g', '/Users/adam.moss/.cache/pre-commit/repo0b_3uta1/commitlint-pre-commit-hook-1.0.0.tgz', '@commitlint/config-conventional') return code: 1 expected return code: 0 stdout: (none) stderr: npm ERR! code ETARGET npm ERR! notarget No matching version found for @commitlint/resolve-extends@^17.3.0. npm ERR! notarget In most cases you or one of your dependencies are requesting npm ERR! notarget a package version that doesn't exist.

npm ERR! A complete log of this run can be found in:
npm ERR!     /Users/adam.moss/.npm/_logs/2022-11-24T13_35_27_856Z-debug-0.log
adam-moss commented 1 year ago

Hmmm. "Fixed" by doing an npm cache clear --force

Now I just need to work out what happened to break the cache as a darwin, crostini, and an ubuntu machine all experienced it :sob:

alessandrojcm commented 1 year ago

Glad you solved it @adam-moss was about to suggest you try just that :slightly_smiling_face: Re the cache, npm can be weird sometimes without any reason :slightly_frowning_face: