search you tried in the issue tracker
4.6.1, "must have package.json or additional_dependencies"
describe your issue
Since v4.6.1, any repo: local hook using language: node without additional_dependencies fails to install its environment:
An unexpected error has occurred: AssertionError: `language: node` must have package.json or additional_dependencies
This worked in v4.6.0 and earlier. Hit in JupyterLab's release CI, where hooks like this one (running against the project's own node_modules) are common.
#3719 changed node.install_environment to only use the prefix's package.json when prefix.exists('.git') is also true:
|
def install_environment( |
|
prefix: Prefix, version: str, additional_dependencies: Sequence[str], |
|
) -> None: |
|
if prefix.exists('.git') and prefix.exists('package.json'): |
|
# this requires a new-enough npm (2019ish?) |
|
pkgs = (f'git+file://{prefix.prefix_dir}', *additional_dependencies) |
|
else: |
|
pkgs = (*additional_dependencies,) |
|
|
|
if not pkgs: |
|
raise AssertionError( |
|
'`language: node` must have package.json or ' |
|
'additional_dependencies', |
|
) |
But for local repos the prefix comes from store.make_local() - the synthesized empty-template directory, which contains empty_template_package.json but is not a git repo. So pkgs is empty and the new assertion fires. Previously the dummy package was installed with plain npm install -g ., which succeeded.
pre-commit --version
4.6.1
.pre-commit-config.yaml
ci:
# Same schedule interval as dependabot see .github/dependabot.yml
autoupdate_schedule: monthly
# skip any check that needs internet access
skip: [prettier, eslint, stylelint, shellcheck]
default_language_version:
node: system
repos:
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v6.0.0
hooks:
- id: forbid-new-submodules
- id: end-of-file-fixer
exclude: galata/.*-snapshots
- id: check-case-conflict
- id: check-executables-have-shebangs
- id: requirements-txt-fixer
- id: check-added-large-files
- id: check-toml
- id: check-yaml
- id: debug-statements
- id: check-builtin-literals
- id: trailing-whitespace
exclude: .bumpversion.cfg
- id: check-merge-conflict
- id: check-symlinks
- id: mixed-line-ending
- repo: https://github.com/python-jsonschema/check-jsonschema
rev: 0.37.4
hooks:
- id: check-github-workflows
# Check zizmor version is aligned with the one in .github/workflows/zizmor.yml
- repo: https://github.com/zizmorcore/zizmor-pre-commit
rev: e3eebf65325ccc992422292cb7a4baee967cf815 # frozen: v1.26.1
hooks:
- id: zizmor
args: ["--offline"]
- repo: https://github.com/codespell-project/codespell
rev: v2.4.2
hooks:
- id: codespell
args:
- --ignore-words=.codespellignore
- --skip=docs/source/api/**,docs/source/getting_started/changelog.md
files: \.(md|rst|txt)$
# Check ruff version is aligned with the one in pyproject.toml
- repo: https://github.com/astral-sh/ruff-pre-commit
rev: v0.15.20
hooks:
- id: ruff
args: ["--fix"]
- id: ruff-format
- repo: local
hooks:
- id: prettier
name: prettier
entry: jlpm
args: [run, 'prettier:files']
language: node
types_or: [json, ts, tsx, javascript, jsx, css]
exclude: \.ipynb$
- id: eslint
name: eslint
entry: 'npm run eslint:files'
language: node
types_or: [ts, tsx, javascript, jsx]
- id: stylelint
name: stylelint
entry: 'npm run stylelint:files'
language: node
types: [css]
- id: shellcheck
name: shellcheck
entry: bash ./scripts/shellcheck_lint.sh
language: python
additional_dependencies: [shellcheck-py==0.11.0.1]
pass_filenames: false
files: \.sh$
- id: integrity
name: integrity
entry: 'npm run integrity --force'
language: node
stages: [pre-push]
~/.cache/pre-commit/pre-commit.log (if present)
No response
search you tried in the issue tracker
4.6.1, "must have package.json or additional_dependencies"
describe your issue
Since v4.6.1, any
repo: localhook usinglanguage: nodewithoutadditional_dependenciesfails to install its environment:This worked in v4.6.0 and earlier. Hit in JupyterLab's release CI, where hooks like this one (running against the project's own node_modules) are common.
#3719 changed
node.install_environmentto only use the prefix'spackage.jsonwhenprefix.exists('.git')is also true:pre-commit/pre_commit/languages/node.py
Lines 76 to 89 in 242ce8a
But for local repos the prefix comes from
store.make_local()- the synthesized empty-template directory, which containsempty_template_package.jsonbut is not a git repo. Sopkgsis empty and the new assertion fires. Previously the dummy package was installed with plainnpm install -g ., which succeeded.pre-commit --version
4.6.1
.pre-commit-config.yaml
~/.cache/pre-commit/pre-commit.log (if present)
No response