Repository navigation
Closed
Closed
Copy link
Labels
Description
Hi.
I'm getting the error below both on Python 3.10.0 and 3.9.7, only on this mirrors-prettier repo.
[INFO] Installing environment for https://github.com/pre-commit/mirrors-prettier.
[INFO] Once installed this environment will be reused.
[INFO] This may take a few minutes...
An unexpected error has occurred: CalledProcessError: command: ('/Users/aa/.pyenv/versions/3.10.0/bin/python3', '/Users/aa/.cache/pre-commit-zipapp/veR-6hXwmzX2ScBOxSDU3KDEapmTGSUiy_rUDxSkW24/python', '-mnodeenv', '--prebuilt', '--clean-src', '/Users/aa/.cache/pre-commit/repoj2j9vjbi/node_env-system', '-n', 'system')
return code: 1
expected return code: 0
stdout: (none)
stderr:
Traceback (most recent call last):
File "/Users/aa/.cache/pre-commit-zipapp/veR-6hXwmzX2ScBOxSDU3KDEapmTGSUiy_rUDxSkW24/python", line 48, in <module>
exit(main())
File "/Users/aa/.cache/pre-commit-zipapp/veR-6hXwmzX2ScBOxSDU3KDEapmTGSUiy_rUDxSkW24/python", line 32, in main
runpy.run_module(args.m, run_name='__main__', alter_sys=True)
File "/Users/aa/.pyenv/versions/3.10.0/lib/python3.10/runpy.py", line 209, in run_module
return _run_module_code(code, init_globals, run_name, mod_spec)
File "/Users/aa/.pyenv/versions/3.10.0/lib/python3.10/runpy.py", line 96, in _run_module_code
_run_code(code, mod_globals, init_globals,
File "/Users/aa/.pyenv/versions/3.10.0/lib/python3.10/runpy.py", line 86, in _run_code
exec(code, run_globals)
File "/Users/aa/.cache/pre-commit-zipapp/veR-6hXwmzX2ScBOxSDU3KDEapmTGSUiy_rUDxSkW24/wheels/nodeenv-1.6.0-py2.py3-none-any.whl/nodeenv.py", line 48, in <module>
ModuleNotFoundError: No module named 'pkg_resources'
Check the log at /Users/aa/.cache/pre-commit/pre-commit.log
make: *** [.cache/make/pre-commit] Error 3
- Other pre-commit repos work fine.
- None of them are NodeJS repos as far as I know.
- It's happening on a freshly installed computer; it works on my old one.
- I wonder if it has something to do with my NodeJS installation, but I'm not sure and I don't know how to debug it.
- Let me know if I have to post more information about my system.
Below is what I tried so far, to no success.
I'd appreciate any lead, hint or help.
Thanks!
I tried reinstalling setuptools with both python executables:
Details
❯ /Users/aa/.pyenv/versions/3.10.0/bin/python3 -m pip install -U pip setuptools
Requirement already satisfied: pip in /Users/aa/.pyenv/versions/3.10.0/lib/python3.10/site-packages (21.3.1)
Requirement already satisfied: setuptools in /Users/aa/.pyenv/versions/3.10.0/lib/python3.10/site-packages (58.5.3)
❯ /Users/aa/.cache/pre-commit-zipapp/veR-6hXwmzX2ScBOxSDU3KDEapmTGSUiy_rUDxSkW24/python -m ensurepip
Looking in links: /var/folders/t_/w0p3tjc95tjd0vld929q66rh0000gn/T/tmpcc0nkqh6
Requirement already satisfied: setuptools in /Users/aa/.pyenv/versions/3.10.0/lib/python3.10/site-packages (58.5.3)
Requirement already satisfied: pip in /Users/aa/.pyenv/versions/3.10.0/lib/python3.10/site-packages (21.3.1)
❯ /Users/aa/.cache/pre-commit-zipapp/veR-6hXwmzX2ScBOxSDU3KDEapmTGSUiy_rUDxSkW24/python -m pip install -U pip setuptools
Traceback (most recent call last):
File "/Users/aa/.cache/pre-commit-zipapp/veR-6hXwmzX2ScBOxSDU3KDEapmTGSUiy_rUDxSkW24/python", line 48, in <module>
exit(main())
File "/Users/aa/.cache/pre-commit-zipapp/veR-6hXwmzX2ScBOxSDU3KDEapmTGSUiy_rUDxSkW24/python", line 32, in main
runpy.run_module(args.m, run_name='__main__', alter_sys=True)
File "/Users/aa/.pyenv/versions/3.10.0/lib/python3.10/runpy.py", line 205, in run_module
mod_name, mod_spec, code = _get_module_details(mod_name)
File "/Users/aa/.pyenv/versions/3.10.0/lib/python3.10/runpy.py", line 140, in _get_module_details
raise error("No module named %s" % mod_name)
ImportError: No module named pip
Here are the contents of /Users/aa/.cache/pre-commit/pre-commit.log:
/Users/aa/.cache/pre-commit/pre-commit.log
version information
pre-commit version: 2.15.0
sys.version:
3.10.0 (default, Oct 31 2021, 00:48:30) [Clang 12.0.5 (clang-1205.0.22.11)]
sys.executable: /Users/aa/.cache/pre-commit-zipapp/veR-6hXwmzX2ScBOxSDU3KDEapmTGSUiy_rUDxSkW24/python
os.name: posix
sys.platform: darwin
error information
An unexpected error has occurred: CalledProcessError: command: ('/Users/aa/.pyenv/versions/3.10.0/bin/python3', '/Users/aa/.cache/pre-commit-zipapp/veR-6hXwmzX2ScBOxSDU3KDEapmTGSUiy_rUDxSkW24/python', '-mnodeenv', '--prebuilt', '--clean-src', '/Users/aa/.cache/pre-commit/repoj2j9vjbi/node_env-system', '-n', 'system')
return code: 1
expected return code: 0
stdout: (none)
stderr:
Traceback (most recent call last):
File "/Users/aa/.cache/pre-commit-zipapp/veR-6hXwmzX2ScBOxSDU3KDEapmTGSUiy_rUDxSkW24/python", line 48, in <module>
exit(main())
File "/Users/aa/.cache/pre-commit-zipapp/veR-6hXwmzX2ScBOxSDU3KDEapmTGSUiy_rUDxSkW24/python", line 32, in main
runpy.run_module(args.m, run_name='__main__', alter_sys=True)
File "/Users/aa/.pyenv/versions/3.10.0/lib/python3.10/runpy.py", line 209, in run_module
return _run_module_code(code, init_globals, run_name, mod_spec)
File "/Users/aa/.pyenv/versions/3.10.0/lib/python3.10/runpy.py", line 96, in _run_module_code
_run_code(code, mod_globals, init_globals,
File "/Users/aa/.pyenv/versions/3.10.0/lib/python3.10/runpy.py", line 86, in _run_code
exec(code, run_globals)
File "/Users/aa/.cache/pre-commit-zipapp/veR-6hXwmzX2ScBOxSDU3KDEapmTGSUiy_rUDxSkW24/wheels/nodeenv-1.6.0-py2.py3-none-any.whl/nodeenv.py", line 48, in <module>
ModuleNotFoundError: No module named 'pkg_resources'
Traceback (most recent call last):
File "/Users/aa/.cache/pre-commit-zipapp/veR-6hXwmzX2ScBOxSDU3KDEapmTGSUiy_rUDxSkW24/wheels/pre_commit-2.15.0-py2.py3-none-any.whl/pre_commit/error_handler.py", line 65, in error_handler
yield
File "/Users/aa/.cache/pre-commit-zipapp/veR-6hXwmzX2ScBOxSDU3KDEapmTGSUiy_rUDxSkW24/wheels/pre_commit-2.15.0-py2.py3-none-any.whl/pre_commit/main.py", line 396, in main
return run(args.config, store, args)
File "/Users/aa/.cache/pre-commit-zipapp/veR-6hXwmzX2ScBOxSDU3KDEapmTGSUiy_rUDxSkW24/wheels/pre_commit-2.15.0-py2.py3-none-any.whl/pre_commit/commands/run.py", line 417, in run
install_hook_envs(to_install, store)
File "/Users/aa/.cache/pre-commit-zipapp/veR-6hXwmzX2ScBOxSDU3KDEapmTGSUiy_rUDxSkW24/wheels/pre_commit-2.15.0-py2.py3-none-any.whl/pre_commit/repository.py", line 224, in install_hook_envs
_hook_install(hook)
File "/Users/aa/.cache/pre-commit-zipapp/veR-6hXwmzX2ScBOxSDU3KDEapmTGSUiy_rUDxSkW24/wheels/pre_commit-2.15.0-py2.py3-none-any.whl/pre_commit/repository.py", line 82, in _hook_install
lang.install_environment(
File "/Users/aa/.cache/pre-commit-zipapp/veR-6hXwmzX2ScBOxSDU3KDEapmTGSUiy_rUDxSkW24/wheels/pre_commit-2.15.0-py2.py3-none-any.whl/pre_commit/languages/node.py", line 97, in install_environment
cmd_output_b(*cmd)
File "/Users/aa/.cache/pre-commit-zipapp/veR-6hXwmzX2ScBOxSDU3KDEapmTGSUiy_rUDxSkW24/wheels/pre_commit-2.15.0-py2.py3-none-any.whl/pre_commit/util.py", line 154, in cmd_output_b
raise CalledProcessError(returncode, cmd, retcode, stdout_b, stderr_b)
pre_commit.util.CalledProcessError: command: ('/Users/aa/.pyenv/versions/3.10.0/bin/python3', '/Users/aa/.cache/pre-commit-zipapp/veR-6hXwmzX2ScBOxSDU3KDEapmTGSUiy_rUDxSkW24/python', '-mnodeenv', '--prebuilt', '--clean-src', '/Users/aa/.cache/pre-commit/repoj2j9vjbi/node_env-system', '-n', 'system')
return code: 1
expected return code: 0
stdout: (none)
stderr:
Traceback (most recent call last):
File "/Users/aa/.cache/pre-commit-zipapp/veR-6hXwmzX2ScBOxSDU3KDEapmTGSUiy_rUDxSkW24/python", line 48, in <module>
exit(main())
File "/Users/aa/.cache/pre-commit-zipapp/veR-6hXwmzX2ScBOxSDU3KDEapmTGSUiy_rUDxSkW24/python", line 32, in main
runpy.run_module(args.m, run_name='__main__', alter_sys=True)
File "/Users/aa/.pyenv/versions/3.10.0/lib/python3.10/runpy.py", line 209, in run_module
return _run_module_code(code, init_globals, run_name, mod_spec)
File "/Users/aa/.pyenv/versions/3.10.0/lib/python3.10/runpy.py", line 96, in _run_module_code
_run_code(code, mod_globals, init_globals,
File "/Users/aa/.pyenv/versions/3.10.0/lib/python3.10/runpy.py", line 86, in _run_code
exec(code, run_globals)
File "/Users/aa/.cache/pre-commit-zipapp/veR-6hXwmzX2ScBOxSDU3KDEapmTGSUiy_rUDxSkW24/wheels/nodeenv-1.6.0-py2.py3-none-any.whl/nodeenv.py", line 48, in <module>
ModuleNotFoundError: No module named 'pkg_resources'
Activity
asottile commentedon Nov 6, 2021
it looks like you're using the zipapp and that
nodeenvis missing a dependency onsetuptools(wherepkg_resourcescomes from) -- probably worth a PR hereandreoliwa commentedon Nov 6, 2021
Thanks for the tip.
Requiring
setuptoolsonnodeenvdidn't work.I tested it locally:
setuptoolstonodeenv'ssetup.py.install_requires=["setuptools"],install_requires=["setuptools>58"],python setup.py bdist_wheel.~/.cache/pre-commit-zipapp/<subdir>/wheels/.pre-commit run -aagain.pre-commit cleanthere.But this worked instead:
Modifying the python shim locally on
~/.cache/pre-commit-zipapp/<subdir>/pythonto append thesite-packagespath at the end ofsys.path.Running
pre-commit run -aagain.If this is the right code to modify, I can create a pull request.
I don't know the impact of this change, if it breaks tests, etc.
Let me know your thoughts.
Thanks!
asottile commentedon Nov 6, 2021
no so the reason it would need to have an
install_requires=['setuptools']there is so that thesetuptoolswheel also gets pulled in when building the zipapp (if you, for instance, add asetuptools-....whlinto that wheel directory it'll start working)the patch you suggested above is not correct, the zipapp intentionally isolates itself from the system
andreoliwa commentedon Nov 6, 2021
Oh, I see... I got it now, thanks.
Indeed it worked with
setuptools-58.5.3-py3-none-any.whlon thewheelssubdir.I'll create a pull request on
nodeenv. 👍🏻Require setuptools (because of pkg_resources)
asottile commentedon Nov 30, 2021
as a workaround until
nodeenvreleases I'm going to bundlesetuptoolsin the zipappadd setuptools to the zipapp. resolves pre-commit#2122
SandeepGamot commentedon Nov 7, 2023
brew install python-setuptoolsworked for me for versionpre-commit 3.5.0(installed via brew)asottile commentedon Nov 7, 2023
@SandeepGamot you must have some different issue entirely -- this is specifically about the zipapp and your action probably did not fix it. pre-commit doesn't depend on pkg_resources
avandekleut commentedon Nov 25, 2023
@SandeepGamot Your command also worked for me using pre-commit 3.5.1 installed via brew. Sorry to add to this thread, but this is the top search result for the error.
asottile commentedon Nov 25, 2023
please report to homebrew instead of hacking around it here
add setuptools to the zipapp. resolves pre-commit#2122