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

Pre-commit hook poetry-lock not using expected python runtime #6946

Closed
4 tasks done
mijdavis2 opened this issue Nov 2, 2022 · 5 comments · Fixed by #6989
Closed
4 tasks done

Pre-commit hook poetry-lock not using expected python runtime #6946

mijdavis2 opened this issue Nov 2, 2022 · 5 comments · Fixed by #6989
Labels
kind/question User questions (candidates for conversion to discussion) status/external-issue Issue is caused by external project (platform, dep, etc)

Comments

@mijdavis2
Copy link

  • I am on the latest stable Poetry version, installed using a recommended method.
  • I have searched the issues of this repo and believe that this is not a duplicate.
  • I have consulted the FAQ and blog for any relevant entries or release notes.
  • If an exception occurs when executing a command, I executed it again in debug mode (-vvv option) and have included the output below.

Issue

The pre-commit hook for poetry-lock is not using the expected python runtime (using pyenv). Note in below screenshot that the desired version is set globally, in poetry venv, and via poetry env use. For some reason, poetry-lock is using a different runtime (3.9.6), which is not even used in fresh terminals.

Screenshot from 2022-11-02 06-54-25

poetry-lock..............................................................Failed
- hook id: poetry-lock
- exit code: 1

Loading configuration file /home/mjd/.config/pypoetry/config.toml

  Stack trace:

  8  ~/.cache/pre-commit/repohphsqhlu/py_env-python3/lib/python3.9/site-packages/cleo/application.py:329 in run
      327│ 
      328│             try:
    → 329│                 exit_code = self._run(io)
      330│             except Exception as e:
      331│                 if not self._catch_exceptions:

  7  ~/.cache/pre-commit/repohphsqhlu/py_env-python3/lib/python3.9/site-packages/poetry/console/application.py:185 in _run
      183│         self._load_plugins(io)
      184│ 
    → 185│         exit_code: int = super()._run(io)
      186│         return exit_code
      187│ 

  6  ~/.cache/pre-commit/repohphsqhlu/py_env-python3/lib/python3.9/site-packages/cleo/application.py:423 in _run
      421│             io.input.set_stream(stream)
      422│ 
    → 423│         exit_code = self._run_command(command, io)
      424│         self._running_command = None
      425│ 

  5  ~/.cache/pre-commit/repohphsqhlu/py_env-python3/lib/python3.9/site-packages/cleo/application.py:465 in _run_command
      463│ 
      464│         if error is not None:
    → 465│             raise error
      466│ 
      467│         return event.exit_code

  4  ~/.cache/pre-commit/repohphsqhlu/py_env-python3/lib/python3.9/site-packages/cleo/application.py:446 in _run_command
      444│ 
      445│         try:
    → 446│             self._event_dispatcher.dispatch(event, COMMAND)
      447│ 
      448│             if event.command_should_run():

  3  ~/.cache/pre-commit/repohphsqhlu/py_env-python3/lib/python3.9/site-packages/cleo/events/event_dispatcher.py:23 in dispatch
       21│ 
       22│         if listeners:
    →  23│             self._do_dispatch(listeners, event_name, event)
       24│ 
       25│         return event

  2  ~/.cache/pre-commit/repohphsqhlu/py_env-python3/lib/python3.9/site-packages/cleo/events/event_dispatcher.py:84 in _do_dispatch
       82│                 break
       83│ 
    →  84│             listener(event, event_name, self)
       85│ 
       86│     def _sort_listeners(self, event_name: str) -> None:

  1  ~/.cache/pre-commit/repohphsqhlu/py_env-python3/lib/python3.9/site-packages/poetry/console/application.py:294 in configure_env
      292│ 
      293│         env_manager = EnvManager(poetry)
    → 294│         env = env_manager.create_venv(io)
      295│ 
      296│         if env.is_venv() and io.is_verbose():

  InvalidCurrentPythonVersionError

  Current Python version (3.9.6) is not allowed by the project (3.8.10).
  Please change python executable via the "env use" command.

  at ~/.cache/pre-commit/repohphsqhlu/py_env-python3/lib/python3.9/site-packages/poetry/utils/env.py:844 in create_venv
       840│             current_python = Version.parse(
       841│                 ".".join(str(c) for c in env.version_info[:3])
       842│             )
       843│             if not self._poetry.package.python_constraint.allows(current_python):
    →  844│                 raise InvalidCurrentPythonVersionError(
       845│                     self._poetry.package.python_versions, str(current_python)
       846│                 )
       847│             return env
       848│

Content of ~/.config/pypoetry/config.toml:

[virtualenvs]
in-project = true
@mijdavis2 mijdavis2 added kind/bug Something isn't working as expected status/triage This issue needs to be triaged labels Nov 2, 2022
@mijdavis2 mijdavis2 changed the title Pre-commit poetry-lock not using expected python runtime Pre-commit hook poetry-lock not using expected python runtime Nov 2, 2022
@dimbleby
Copy link
Contributor

dimbleby commented Nov 2, 2022

not a poetry question

https://pre-commit.com/#overriding-language-version

@neersighted neersighted added kind/question User questions (candidates for conversion to discussion) status/external-issue Issue is caused by external project (platform, dep, etc) and removed kind/bug Something isn't working as expected status/triage This issue needs to be triaged labels Nov 2, 2022
@rafrafek
Copy link
Contributor

rafrafek commented Nov 7, 2022

not a poetry question

https://pre-commit.com/#overriding-language-version

It does not work because Poetry has specified Python version in hooks definition. Please remove version definition.

https://github.com/python-poetry/poetry/blob/master/.pre-commit-hooks.yaml

@dimbleby
Copy link
Contributor

dimbleby commented Nov 7, 2022

no point in making updates in closed issues - please submit a merge request

@rafrafek
Copy link
Contributor

rafrafek commented Nov 7, 2022

Ok!

pre-commit/pre-commit#2586 (comment)

Copy link

github-actions bot commented Mar 1, 2024

This issue has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Mar 1, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
kind/question User questions (candidates for conversion to discussion) status/external-issue Issue is caused by external project (platform, dep, etc)
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants