Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Errors when running pre-commit hooks #6

Closed
yoavnash opened this issue May 30, 2022 · 5 comments
Closed

Errors when running pre-commit hooks #6

yoavnash opened this issue May 30, 2022 · 5 comments
Assignees
Labels
question Further information is requested

Comments

@yoavnash
Copy link
Member

The pre-commit file of the standard-app-api repo creates a lot of problems on both Windows and Linux

Windows:

An unexpected error has occurred: CalledProcessError: command: ('C:\\Users\\Yoav\\.cache\\pre-commit\\repoke2a5myj\\py_env-default\\Scripts\\python.EXE', '-mpip', 'install', '.')
return code: 1
expected return code: 0
stdout: (none)
stderr:
    Traceback (most recent call last):
      File "C:\Users\Yoav\Anaconda3\envs\p310\lib\runpy.py", line 196, in _run_module_as_main
        return _run_code(code, main_globals, None,
      File "C:\Users\Yoav\Anaconda3\envs\p310\lib\runpy.py", line 86, in _run_code
        exec(code, run_globals)
      File "C:\Users\Yoav\.cache\pre-commit\repoke2a5myj\py_env-default\lib\site-packages\pip\__main__.py", line 29, in <module>
        from pip._internal.cli.main import main as _main
      File "C:\Users\Yoav\.cache\pre-commit\repoke2a5myj\py_env-default\lib\site-packages\pip\_internal\cli\main.py", line 9, in <module>
        from pip._internal.cli.autocompletion import autocomplete
      File "C:\Users\Yoav\.cache\pre-commit\repoke2a5myj\py_env-default\lib\site-packages\pip\_internal\cli\autocompletion.py", line 10, in <module>
        from pip._internal.cli.main_parser import create_main_parser
      File "C:\Users\Yoav\.cache\pre-commit\repoke2a5myj\py_env-default\lib\site-packages\pip\_internal\cli\main_parser.py", line 8, in <module>
        from pip._internal.cli import cmdoptions
      File "C:\Users\Yoav\.cache\pre-commit\repoke2a5myj\py_env-default\lib\site-packages\pip\_internal\cli\cmdoptions.py", line 23, in <module>
        from pip._internal.cli.parser import ConfigOptionParser
      File "C:\Users\Yoav\.cache\pre-commit\repoke2a5myj\py_env-default\lib\site-packages\pip\_internal\cli\parser.py", line 12, in <module>
        from pip._internal.configuration import Configuration, ConfigurationError
      File "C:\Users\Yoav\.cache\pre-commit\repoke2a5myj\py_env-default\lib\site-packages\pip\_internal\configuration.py", line 24, in <module>
        from pip._internal.utils import appdirs
      File "C:\Users\Yoav\.cache\pre-commit\repoke2a5myj\py_env-default\lib\site-packages\pip\_internal\utils\appdirs.py", line 13, in <module>
        from pip._vendor import platformdirs as _appdirs
      File "C:\Users\Yoav\.cache\pre-commit\repoke2a5myj\py_env-default\lib\site-packages\pip\_vendor\platformdirs\__init__.py", line 33, in <module>
        PlatformDirs = _set_platform_dir_class()  #: Currently active platform
      File "C:\Users\Yoav\.cache\pre-commit\repoke2a5myj\py_env-default\lib\site-packages\pip\_vendor\platformdirs\__init__.py", line 29, in _set_platform_dir_class
        result: type[PlatformDirsABC] = getattr(importlib.import_module(module), name)
      File "C:\Users\Yoav\Anaconda3\envs\p310\lib\importlib\__init__.py", line 126, in import_module
        return _bootstrap._gcd_import(name[level:], package, level)
      File "C:\Users\Yoav\.cache\pre-commit\repoke2a5myj\py_env-default\lib\site-packages\pip\_vendor\platformdirs\windows.py", line 3, in <module>
        import ctypes
      File "C:\Users\Yoav\Anaconda3\envs\p310\lib\ctypes\__init__.py", line 8, in <module>
        from _ctypes import Union, Structure, Array
    ImportError: DLL load failed while importing _ctypes: The specified module could not be found.

Linux:

An unexpected error has occurred: CalledProcessError: command: ('/root/.cache/pre-commit/repor0ureqic/py_env-3.10/bin/python', '-mpip', 'install', '.', 'click==8.1.3', 'fastapi==0.75.2', 'pydantic==1.9.0', 'pytest==7.1.2', 'types-requests==2.27.27', 'types-ujson==4.2.1')
return code: 1
expected return code: 0
stdout: (none)
stderr:
    Traceback (most recent call last):
      File "/usr/lib/python3.10/runpy.py", line 196, in _run_module_as_main
        return _run_code(code, main_globals, None,
      File "/usr/lib/python3.10/runpy.py", line 86, in _run_code
        exec(code, run_globals)
      File "/root/.cache/pre-commit/repor0ureqic/py_env-3.10/lib/python3.10/site-packages/pip/__main__.py", line 29, in <module>
        from pip._internal.cli.main import main as _main
      File "/root/.cache/pre-commit/repor0ureqic/py_env-3.10/lib/python3.10/site-packages/pip/_internal/cli/main.py", line 9, in <module>
        from pip._internal.cli.autocompletion import autocomplete
      File "/root/.cache/pre-commit/repor0ureqic/py_env-3.10/lib/python3.10/site-packages/pip/_internal/cli/autocompletion.py", line 10, in <module>
        from pip._internal.cli.main_parser import create_main_parser
      File "/root/.cache/pre-commit/repor0ureqic/py_env-3.10/lib/python3.10/site-packages/pip/_internal/cli/main_parser.py", line 8, in <module>
        from pip._internal.cli import cmdoptions
      File "/root/.cache/pre-commit/repor0ureqic/py_env-3.10/lib/python3.10/site-packages/pip/_internal/cli/cmdoptions.py", line 23, in <module>
        from pip._internal.cli.parser import ConfigOptionParser
      File "/root/.cache/pre-commit/repor0ureqic/py_env-3.10/lib/python3.10/site-packages/pip/_internal/cli/parser.py", line 12, in <module>
        from pip._internal.configuration import Configuration, ConfigurationError
      File "/root/.cache/pre-commit/repor0ureqic/py_env-3.10/lib/python3.10/site-packages/pip/_internal/configuration.py", line 26, in <module>
        from pip._internal.utils.logging import getLogger
      File "/root/.cache/pre-commit/repor0ureqic/py_env-3.10/lib/python3.10/site-packages/pip/_internal/utils/logging.py", line 27, in <module>
        from pip._internal.utils.misc import ensure_dir
      File "/root/.cache/pre-commit/repor0ureqic/py_env-3.10/lib/python3.10/site-packages/pip/_internal/utils/misc.py", line 39, in <module>
        from pip._internal.locations import get_major_minor_version
      File "/root/.cache/pre-commit/repor0ureqic/py_env-3.10/lib/python3.10/site-packages/pip/_internal/locations/__init__.py", line 14, in <module>
        from . import _distutils, _sysconfig
      File "/root/.cache/pre-commit/repor0ureqic/py_env-3.10/lib/python3.10/site-packages/pip/_internal/locations/_distutils.py", line 9, in <module>
        from distutils.cmd import Command as DistutilsCommand
    ModuleNotFoundError: No module named 'distutils.cmd'
@csadorf
Copy link
Collaborator

csadorf commented May 30, 2022

The issue observed on windows is probably related to: pre-commit/pre-commit#1329

@csadorf csadorf self-assigned this May 30, 2022
@csadorf csadorf added the question Further information is requested label May 31, 2022
@csadorf
Copy link
Collaborator

csadorf commented May 31, 2022

@yoavnash Thank you for reporting. I need more information to be able to address this issue, would you mind answering the following questions?

  1. Which pre-commit version are you running (pre-commit --version)?
  2. How did you install it? Pip / conda? (which pre-commit)
  3. Which version of conda/anaconda do you use (conda --version / anaconda --version)?
  4. Which exact operating system versions are you using?

@yoavnash
Copy link
Member Author

yoavnash commented Jun 2, 2022

In Windows:

  • Pre-commit version: 2.19.0
  • Installation: conda
  • Conda version: 4.13.0
  • Operation: For example, running the pre-commit run --all-files produces the errors

I just discovered that the problem resolves itself when running pre-commit on the base environment of conda.

@csadorf
Copy link
Collaborator

csadorf commented Jun 2, 2022

In Windows:

  • Pre-commit version: 2.19.0
  • Installation: conda
  • Conda version: 4.13.0
  • Operation: For example, running the pre-commit run --all-files produces the errors

Thanks for providing the information.

I just discovered that the problem resolves itself when running pre-commit on the base environment of conda.

Yes, you should always install the pre-commit into the base environment. I assume we can close this then?

@yoavnash
Copy link
Member Author

yoavnash commented Jun 2, 2022

Indeed. Thanks.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
question Further information is requested
Projects
None yet
Development

No branches or pull requests

2 participants