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

poetry install Fails to create in-project virtual environment #8016

Closed
4 tasks done
abrennan-ams opened this issue May 26, 2023 · 4 comments
Closed
4 tasks done

poetry install Fails to create in-project virtual environment #8016

abrennan-ams opened this issue May 26, 2023 · 4 comments
Labels
kind/bug Something isn't working as expected status/duplicate Duplicate issues

Comments

@abrennan-ams
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

After upgrading from poetry v1.4.2 to v1.5.0, I cannot create a new virtual environment in the project directory. The virtual environment was removed with rm -rf .venv. Switching back to v1.4.2 resolves the issue with virtual environment creation.

A possible explanation is pipx python is called from poetry/utils/env.py

poetry.toml

[virtualenvs]
in-project = true

[installer]
max-workers = 1

Debug Output

> poetry install -vvv
Loading configuration file /home/aaron/.config/pypoetry/config.toml
Loading configuration file /workspaces/aaron/test/poetry.toml

  Stack trace:

  1  /tools/infrastructure/pipx/venvs/poetry/lib/python3.9/site-packages/poetry/utils/env.py:1501 in _run
      1499│         try:
      1500│             if input_:
    → 1501│                 output = subprocess.run(
      1502│                     cmd,
      1503│                     stdout=subprocess.PIPE,

  CalledProcessError

  Command '['python', '-I', '-W', 'ignore', '-']' returned non-zero exit status 2.

  at /usr/local/lib/python3.9/subprocess.py:528 in run
       524│             # We don't call process.wait() as .__exit__ does that for us.
       525│             raise
       526│         retcode = process.poll()
       527│         if check and retcode:
    →  528│             raise CalledProcessError(retcode, process.args,
       529│                                      output=stdout, stderr=stderr)
       530│     return CompletedProcess(process.args, retcode, stdout, stderr)
       531│ 
       532│ 

The following error occurred when trying to handle this error:


  Stack trace:

  14  /tools/infrastructure/pipx/venvs/poetry/lib/python3.9/site-packages/cleo/application.py:327 in run
       325│ 
       326│             try:
     → 327│                 exit_code = self._run(io)
       328│             except BrokenPipeError:
       329│                 # If we are piped to another process, it may close early and send a

  13  /tools/infrastructure/pipx/venvs/poetry/lib/python3.9/site-packages/poetry/console/application.py:190 in _run
       188│         self._load_plugins(io)
       189│ 
     → 190│         exit_code: int = super()._run(io)
       191│         return exit_code
       192│ 

  12  /tools/infrastructure/pipx/venvs/poetry/lib/python3.9/site-packages/cleo/application.py:431 in _run
       429│             io.input.interactive(interactive)
       430│ 
     → 431│         exit_code = self._run_command(command, io)
       432│         self._running_command = None
       433│ 

  11  /tools/infrastructure/pipx/venvs/poetry/lib/python3.9/site-packages/cleo/application.py:473 in _run_command
       471│ 
       472│         if error is not None:
     → 473│             raise error
       474│ 
       475│         return terminate_event.exit_code

  10  /tools/infrastructure/pipx/venvs/poetry/lib/python3.9/site-packages/cleo/application.py:454 in _run_command
       452│ 
       453│         try:
     → 454│             self._event_dispatcher.dispatch(command_event, COMMAND)
       455│ 
       456│             if command_event.command_should_run():

   9  /tools/infrastructure/pipx/venvs/poetry/lib/python3.9/site-packages/cleo/events/event_dispatcher.py:26 in dispatch
        24│ 
        25│         if listeners:
     →  26│             self._do_dispatch(listeners, event_name, event)
        27│ 
        28│         return event

   8  /tools/infrastructure/pipx/venvs/poetry/lib/python3.9/site-packages/cleo/events/event_dispatcher.py:89 in _do_dispatch
        87│                 break
        88│ 
     →  89│             listener(event, event_name, self)
        90│ 
        91│     def _sort_listeners(self, event_name: str) -> None:

   7  /tools/infrastructure/pipx/venvs/poetry/lib/python3.9/site-packages/poetry/console/application.py:299 in configure_env
       297│ 
       298│         env_manager = EnvManager(poetry, io=io)
     → 299│         env = env_manager.create_venv()
       300│ 
       301│         if env.is_venv() and io.is_verbose():

   6  /tools/infrastructure/pipx/venvs/poetry/lib/python3.9/site-packages/poetry/utils/env.py:870 in create_venv
        868│ 
        869│         cwd = self._poetry.file.path.parent
     →  870│         env = self.get(reload=True)
        871│ 
        872│         if not env.is_sane():

   5  /tools/infrastructure/pipx/venvs/poetry/lib/python3.9/site-packages/poetry/utils/env.py:704 in get
        702│                 venv = self.in_project_venv
        703│ 
     →  704│                 return VirtualEnv(venv)
        705│ 
        706│             create_venv = self._poetry.config.get("virtualenvs.create", True)

   4  /tools/infrastructure/pipx/venvs/poetry/lib/python3.9/site-packages/poetry/utils/env.py:1669 in __init__
       1667│         # from inside the virtualenv.
       1668│         if base is None:
     → 1669│             output = self.run_python_script(GET_BASE_PREFIX)
       1670│             self._base = Path(output.strip())
       1671│ 

   3  /tools/infrastructure/pipx/venvs/poetry/lib/python3.9/site-packages/poetry/utils/env.py:1479 in run_python_script
       1477│ 
       1478│     def run_python_script(self, content: str, **kwargs: Any) -> str:
     → 1479│         return self.run(
       1480│             self._executable,
       1481│             "-I",

   2  /tools/infrastructure/pipx/venvs/poetry/lib/python3.9/site-packages/poetry/utils/env.py:1471 in run
       1469│     def run(self, bin: str, *args: str, **kwargs: Any) -> str:
       1470│         cmd = self.get_command_from_bin(bin) + list(args)
     → 1471│         return self._run(cmd, **kwargs)
       1472│ 
       1473│     def run_pip(self, *args: str, **kwargs: Any) -> str:

   1  /tools/infrastructure/pipx/venvs/poetry/lib/python3.9/site-packages/poetry/utils/env.py:1723 in _run
       1721│     def _run(self, cmd: list[str], **kwargs: Any) -> str:
       1722│         kwargs["env"] = self.get_temp_environ(environ=kwargs.get("env"))
     → 1723│         return super()._run(cmd, **kwargs)
       1724│ 
       1725│     def get_temp_environ(

  EnvCommandError

  Command ['python', '-I', '-W', 'ignore', '-'] errored with the following return code 2
  
  Error output:
  Unknown option: -I
  usage: python [option] ... [-c cmd | -m mod | file | -] [arg] ...
  Try `python -h' for more information.
  
  
  Input:
  import sys
  
  if hasattr(sys, "real_prefix"):
      print(sys.real_prefix)
  elif hasattr(sys, "base_prefix"):
      print(sys.base_prefix)
  else:
      print(sys.prefix)
  

  at /tools/infrastructure/pipx/venvs/poetry/lib/python3.9/site-packages/poetry/utils/env.py:1517 in _run
      1513│                 output = ""
      1514│             else:
      1515│                 output = subprocess.check_output(cmd, stderr=stderr, env=env, **kwargs)
      1516│         except CalledProcessError as e:
    → 1517│             raise EnvCommandError(e, input=input_)
      1518│ 
      1519│         return decode(output)
      1520│ 
      1521│     def execute(self, bin: str, *args: str, **kwargs: Any) -> int:
@abrennan-ams abrennan-ams added kind/bug Something isn't working as expected status/triage This issue needs to be triaged labels May 26, 2023
@dimbleby
Copy link
Contributor

duplicate #7854, #7957 - per #7854 (comment) - please close

@abrennan-ams
Copy link
Author

Agreed - thank you for the pointer

@dimbleby
Copy link
Contributor

You agreed, but did not close this. Please close

@radoering radoering added status/duplicate Duplicate issues and removed status/triage This issue needs to be triaged labels May 27, 2023
@radoering radoering closed this as not planned Won't fix, can't repro, duplicate, stale May 27, 2023
Copy link

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 Feb 29, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
kind/bug Something isn't working as expected status/duplicate Duplicate issues
Projects
None yet
Development

No branches or pull requests

3 participants