wagtail icon indicating copy to clipboard operation
wagtail copied to clipboard

pre-commit throws error initialising environment

Open enzedonline opened this issue 1 year ago • 2 comments

Issue Summary

I'm working on a fork of wagtail, trying to make a commit with pre-commit installed.

When it comes to initialising the environment for ruff-pre-commit, I see the following errors:

[INFO] Initializing environment for https://github.com/astral-sh/ruff-pre-commit.
[INFO] Initializing environment for https://github.com/pre-commit/mirrors-prettier.
[INFO] Initializing environment for https://github.com/pre-commit/mirrors-prettier:[email protected].
[INFO] Initializing environment for https://github.com/pre-commit/mirrors-eslint.
[INFO] Initializing environment for https://github.com/pre-commit/mirrors-eslint:[email protected],@typescript-eslint/[email protected],@typescript-eslint/[email protected],@wagtail/[email protected].
[INFO] Initializing environment for https://github.com/thibaudcolas/pre-commit-stylelint.
[INFO] Initializing environment for https://github.com/thibaudcolas/pre-commit-stylelint:[email protected],@wagtail/[email protected].
[INFO] Initializing environment for https://github.com/thibaudcolas/curlylint.
[INFO] Initializing environment for https://github.com/rtts/djhtml.
[INFO] Initializing environment for https://github.com/returntocorp/semgrep.
An unexpected error has occurred: CalledProcessError: command: ('C:/Program Files/Git/mingw64/libexec/git-core\\git.EXE', 'checkout', 'v1.40.0')
return code: 1
stdout: (none)
stderr:
    error: cannot stat 'cli/tests/e2e/snapshots/test_autofix/test_autofix_osemfail/rulesautofixterraform-ec2-instance-metadata-options.yaml-autofixterraform-ec2-instance-metadata-options.hcl-dryrun/autofix/terraform-ec2-instance-metadata-options.hcl-dryrun': Filename too long
    error: cannot stat 'cli/tests/e2e/snapshots/test_autofix/test_autofix_osemfail/rulesautofixterraform-ec2-instance-metadata-options.yaml-autofixterraform-ec2-instance-metadata-options.hcl-not-dryrun/autofix/terraform-ec2-instance-metadata-options.hcl-fixed': Filename too long
    error: The following untracked working tree files would be overwritten by checkout:
    	.circleci/README.md
    	.circleci/config.yml
    	.dockerignore
    	.gitattributes
    	.github/CODEOWNERS
    	.github/ISSUE_TEMPLATE/bug_report.md
    	.github/ISSUE_TEMPLATE/feature_request.md
    	.github/PULL_REQUEST_TEMPLATE/release_pr_template.md
    	.github/actionlint.yaml
    	.github/dependabot.yml
    	.github/pull_request_template.md
    	.github/stale.yml
    	.github/workflows/README.md
    	.github/workflows/build-test-core-x86.yaml
    	.github/workflows/build-test-docker.yaml
    	.github/workflows/build-test-javascript.yaml
    	.github/workflows/build-test-manylinux-aarch64.yaml
    	.github/workflows/build-test-manylinux-x86.yaml
    	.github/workflows/build-test-osx-arm64.yaml
    	.github/workflows/build-test-osx-x86.yaml
    	.github/workflows/call-bump-pr-workflow.yml
    	.github/workflows/check-semgrep-pro-version.yml
    	.github/workflows/e2e-semgrep-ci.yml
    	.github/workflows/lint.yml
    	.github/workflows/nightly.yml
    	.github/workflows/open-bump-pr.yml
    	.github/workflows/push-docker.yaml
    	.github/workflows/release.yml
    	.github/workflows/revert-semgrep-docker-image.yml
    	.github/workflows/semgrep.yml
    	.github/workflows/start-release.yml
    	.github/workflows/test-semgrep-pro-latest.yaml
    	.github/workflows/test-semgrep-pro.yaml
    	.github/workflows/tests.yml
    	.github/workflows/update-semgrep-rules.yml
    	.github/workflows/validate-release.yml
    	.gitignore
    	.gitmodules
    	.ocamlformat
    	.pre-commit-config.yaml
    	.pre-commit-hooks.yaml
    	.semgrepignore
    	CHANGELOG.md
    	CODE_OF_CONDUCT.md
    	CONTRIBUTING.md
    	COPYRIGHT
    	Dockerfile
    	INSTALL.md
    	LICENSE
    	Makefile
    	PRIVACY.md
    	README.md
    	SECURITY.md
    	changelog.d/README
    	changelog.d/gh-1234.example
    	cli/LICENSE
    	cli/MANIFEST.in
    	cli/Makefile
    	cli/Pipfile
    	cli/Pipfile.lock
    	cli/bin/pysemgrep
    	cli/bin/semgrep
    	cli/park.cfg
    	cli/pyproject.toml
    	cli/setup.py
    	cli/src/semdep/__init__.py
    	cli/src/semdep/external/__init__.py
    	cli/src/semdep/external/packaging/LICENSE
    	cli/src/semdep/external/packaging/LICENSE.APACHE
    	cli/src/semdep/external/packaging/LICENSE.BSD
    	cli/src/semdep/external/packaging/README
    	cli/src/semdep/external/packaging/__about__.py
    	cli/src/semdep/external/packaging/__init__.py
    	cli/src/semdep/external/packaging/_manylinux.py
    	cli/src/semdep/external/packaging/_musllinux.py
    	cli/src/semdep/external/packaging/_structures.py
    	cli/src/semdep/external/packaging/py.typed
    	cli/src/semdep/external/packaging/specifiers.py
    	cli/src/semdep/external/packaging/tags.py
    	cli/src/semdep/external/packaging/utils.py
    	cli/src/semdep/external/packaging/version.py
    	cli/src/semdep/external/parsy/LICENSE
    	cli/src/semdep/external/parsy/README.rst
    	cli/src/semdep/external/parsy/VENDOR_README.md
    	cli/src/semdep/external/parsy/__init__.py
    	cli/src/semdep/external/parsy/__init__.pyi
    	cli/src/semdep/external/parsy/version.py
    	cli/src/semdep/maven_version.py
    	cli/src/semdep/package_restrictions.py
    	cli/src/semdep/parse_lockfile.py
    	cli/src/semdep/parsers/__init__.py
    	cli/src/semdep/parsers/composer.py
    	cli/src/semdep/parsers/gem.py
    	cli/src/semdep/parsers/go_mod.py
    	cli/src/semdep/parsers/gradle.py
    	cli/src/semdep/parsers/package_lock.py
    	cli/src/semdep/parsers/packages_lock_c_sharp.py
    	cli/src/semdep/parsers/pipfile.py
    	cli/src/semdep/parsers/pnpm.py
    	cli/src/semdep/parsers/poetry.py
    	cli/src/semdep/parsers/pom_tree.py
    	cli/src/semdep/parsers/preprocessors.py
    	cli/src/semdep/parsers/requirements.py
    	cli/src/semdep/parsers/util.py
    	cli/src/semdep/parsers/yarn.py
    	cli/src/semgrep/__init__.py
    	cli/src/semgrep/__main__.py
    	cli/src/semgrep/app/__init__.py
    	cli/src/semgrep/app/auth.py
    	cli/src/semgrep/app/registry.py
    	cli/src/semgrep/app/scans.py
    	cli/src/semgrep/app/session.py
    	cli/src/semgrep/app/version.py
    	cli/src/semgrep/autofix.py
    	cli/src/semgrep/bin/__init__.py
    	cli/src/semgrep/bytesize.py
    	cli/src/semgrep/cli.py
    	cli/src/semgrep/commands/__init__.py
    	cli/src/semgrep/commands/ci.py
    	cli/src/semgrep/commands/install.py
    	cli/src/semgrep/commands/login.py
    	cli/src/semgrep/commands/lsp.py
    	cli/src/semgrep/commands/publish.py
    	cli/src/semgrep/commands/scan.py
    	cli/src/semgrep/commands/wrapp
    Aborting

Aside from the long filename errors, none of those untracked working tree files have been affected by anything in my fork, the only changes are to 2 working files and 2 test files in the images folder.

If it's relevant, I'm working in Windows environment.

Steps to Reproduce

Fork wagtail rep Clone locally pre-commit install Make change and commit

  • I have confirmed that this issue can be reproduced as described on a fresh Wagtail project: Y

Technical details

  • Python version: Run 3.12
  • Django version: 5.0.3
  • Wagtail version: current dev

enzedonline avatar Jun 07 '24 22:06 enzedonline

@enzedonline try git config --system core.longpaths true (source)

zerolab avatar Jun 08 '24 13:06 zerolab

@zerolab Thanks! That's got me past the first lot of errors. Now I'm snagged on a node.js error. Seems to be mis-identifying the OS as win32 instead of win64.

### version information

pre-commit version: 3.7.1
git --version: git version 2.44.1.windows.1
sys.version:
    3.12.0 (tags/v3.12.0:0fb18b0, Oct  2 2023, 13:03:39) [MSC v.1935 64 bit (AMD64)]
sys.executable: C:\Django\wagtail-preserve-svg\.venv\Scripts\python.exe
os.name: nt
sys.platform: win32

### error information

An unexpected error has occurred: CalledProcessError: command: ('C:\\Django\\wagtail-preserve-svg\\.venv\\Scripts\\python.exe', '-mnodeenv', '--prebuilt', '--clean-src', '\\\\?\\C:\\Users\\rich\\.cache\\pre-commit\\repotxk3fvga\\node_env-system', '-n', 'system')
return code: 1
stdout: (none)
stderr:
    Installing system node.js on win32 is not supported!

Traceback (most recent call last):
  File "C:\Django\wagtail-preserve-svg\.venv\Lib\site-packages\pre_commit\error_handler.py", line 73, in error_handler
    yield
  File "C:\Django\wagtail-preserve-svg\.venv\Lib\site-packages\pre_commit\main.py", line 389, in main
    return hook_impl(
           ^^^^^^^^^^
  File "C:\Django\wagtail-preserve-svg\.venv\Lib\site-packages\pre_commit\commands\hook_impl.py", line 271, in hook_impl
    return retv | run(config, store, ns)
                  ^^^^^^^^^^^^^^^^^^^^^^
  File "C:\Django\wagtail-preserve-svg\.venv\Lib\site-packages\pre_commit\commands\run.py", line 442, in run
    install_hook_envs(to_install, store)
  File "C:\Django\wagtail-preserve-svg\.venv\Lib\site-packages\pre_commit\repository.py", line 238, in install_hook_envs
    _hook_install(hook)
  File "C:\Django\wagtail-preserve-svg\.venv\Lib\site-packages\pre_commit\repository.py", line 94, in _hook_install
    lang.install_environment(
  File "C:\Django\wagtail-preserve-svg\.venv\Lib\site-packages\pre_commit\languages\node.py", line 89, in install_environment
    cmd_output_b(*cmd)
  File "C:\Django\wagtail-preserve-svg\.venv\Lib\site-packages\pre_commit\util.py", line 111, in cmd_output_b
    raise CalledProcessError(returncode, cmd, stdout_b, stderr_b)
pre_commit.util.CalledProcessError: command: ('C:\\Django\\wagtail-preserve-svg\\.venv\\Scripts\\python.exe', '-mnodeenv', '--prebuilt', '--clean-src', '\\\\?\\C:\\Users\\rich\\.cache\\pre-commit\\repotxk3fvga\\node_env-system', '-n', 'system')
return code: 1
stdout: (none)
stderr:
    Installing system node.js on win32 is not supported!

enzedonline avatar Jun 08 '24 23:06 enzedonline