Skip to content

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

@mijdavis2

Description

@mijdavis2
  • 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

Metadata

Metadata

Assignees

No one assigned

    Labels

    kind/questionUser questions (candidates for conversion to discussion)status/external-issueIssue is caused by external project (platform, dep, etc)

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions