poetry icon indicating copy to clipboard operation
poetry copied to clipboard

Poetry 1.2.0b2 creates broken virtualenv without bin/ on macOS

Open intgr opened this issue 2 years ago • 2 comments

  • [x] I am on the latest Poetry version.
  • [x] I have searched the issues of this repo and believe that this is not a duplicate.
  • [x] If an exception occurs when executing a command, I executed it again in debug mode (-vvv option).
  • OS version and name: macOS 12.4 (21F79)
  • Poetry version: 1.2.0b2 (beta!)
  • Link of a Gist with the contents of your pyproject.toml file:

Issue

% python3 --version
Python 3.10.2
% poetry --version
Poetry (version 1.2.0b2)
% mkdir testenv2
% cd testenv2
% poetry init -n
% poetry shell -vvv
Loading configuration file .../Library/Application Support/pypoetry/config.toml
Loading configuration file .../Library/Application Support/pypoetry/auth.toml
The virtual environment found in .../Library/Caches/pypoetry/virtualenvs/testenv2-GkgR_jQt-py3.10 seems to be broken.
Recreating virtualenv testenv2-GkgR_jQt-py3.10 in .../Library/Caches/pypoetry/virtualenvs/testenv2-GkgR_jQt-py3.10
Using virtualenv: .../Library/Caches/pypoetry/virtualenvs/testenv2-GkgR_jQt-py3.10
Spawning shell within .../Library/Caches/pypoetry/virtualenvs/testenv2-GkgR_jQt-py3.10
% . .../Library/Caches/pypoetry/virtualenvs/testenv2-GkgR_jQt-py3.10/bin/activate
.: no such file or directory: .../Library/Caches/pypoetry/virtualenvs/testenv2-GkgR_jQt-py3.10/bin/activate
% ls -la .../Library/Caches/pypoetry/virtualenvs/testenv2-GkgR_jQt-py3.10/
total 16
drwxr-xr-x@  6 USERNAME  192 Jun 28 12:17 .
drwxr-xr-x  25 USERNAME  800 Jun 28 12:17 ..
-rw-r--r--   1 USERNAME   40 Jun 28 12:17 .gitignore
drwxr-xr-x   3 USERNAME   96 Jun 28 12:17 lib
-rw-r--r--   1 USERNAME  445 Jun 28 12:17 pyvenv.cfg
drwxr-xr-x   3 USERNAME   96 Jun 28 12:17 usr

Notice there is no bin directory ^

Same happens when I manually delete the virtualenv path and try poetry shell again.

intgr avatar Jun 28 '22 09:06 intgr

As a work-around, I can manually create the virtualenv and Poetry will happily use it.

python3 -m venv .../Library/Caches/pypoetry/virtualenvs/testenv2-GkgR_jQt-py3.10

intgr avatar Jun 28 '22 09:06 intgr

I've just run into this too, Poetry 1.1.14 using the get-poetry.py script on Ubuntu 22.04 with Python 3.10.4

drcongo avatar Aug 03 '22 10:08 drcongo

So I've been having the same issue on an existing Ubuntu 22.04 VM. If I create a new VM, install 1.2.0b3, copy one of my projects to the new VM, poetry works fine (only tested with poetry install for now).

On the old (malfunctioning) VM, if I remove everything I can find related to poetry, do the same install (curl -sSL https://install.python-poetry.org | python3 - --preview) I see this error when running poetry install -vvv:

Creating virtualenv <project-name>-HHTANb4f-py3.10 in /home/<user>/.cache/pypoetry/virtualenvs

  Stack trace:

  16  ~/.local/share/pypoetry/venv/lib/python3.10/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:

  15  ~/.local/share/pypoetry/venv/lib/python3.10/site-packages/poetry/console/application.py:188 in _run
       186│         self._load_plugins(io)
       187│
     → 188│         exit_code: int = super()._run(io)
       189│         return exit_code
       190│

  14  ~/.local/share/pypoetry/venv/lib/python3.10/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│

  13  ~/.local/share/pypoetry/venv/lib/python3.10/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

  12  ~/.local/share/pypoetry/venv/lib/python3.10/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():

  11  ~/.local/share/pypoetry/venv/lib/python3.10/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

  10  ~/.local/share/pypoetry/venv/lib/python3.10/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:

   9  ~/.local/share/pypoetry/venv/lib/python3.10/site-packages/poetry/console/application.py:296 in configure_env
       294│
       295│         env_manager = EnvManager(poetry)
     → 296│         env = env_manager.create_venv(io)
       297│
       298│         if env.is_venv() and io.is_verbose():

   8  ~/.local/share/pypoetry/venv/lib/python3.10/site-packages/poetry/utils/env.py:1002 in create_venv
       1000│             return self.get_system_env()
       1001│
     → 1002│         return VirtualEnv(venv)
       1003│
       1004│     @classmethod

   7  ~/.local/share/pypoetry/venv/lib/python3.10/site-packages/poetry/utils/env.py:1639 in __init__
       1637│         # from inside the virtualenv.
       1638│         if base is None:
     → 1639│             output = self.run_python_script(GET_BASE_PREFIX)
       1640│             assert isinstance(output, str)
       1641│             self._base = Path(output.strip())

   6  ~/.local/share/pypoetry/venv/lib/python3.10/site-packages/poetry/utils/env.py:1420 in run_python_script
       1418│
       1419│     def run_python_script(self, content: str, **kwargs: Any) -> int | str:
     → 1420│         return self.run(self._executable, "-W", "ignore", "-", input_=content, **kwargs)
       1421│
       1422│     def _run(self, cmd: list[str], **kwargs: Any) -> int | str:

   5  ~/.local/share/pypoetry/venv/lib/python3.10/site-packages/poetry/utils/env.py:1412 in run
       1410│     def run(self, bin: str, *args: str, **kwargs: Any) -> str | int:
       1411│         cmd = self.get_command_from_bin(bin) + list(args)
     → 1412│         return self._run(cmd, **kwargs)
       1413│
       1414│     def run_pip(self, *args: str, **kwargs: Any) -> int | str:

   4  ~/.local/share/pypoetry/venv/lib/python3.10/site-packages/poetry/utils/env.py:1707 in _run
       1705│     def _run(self, cmd: list[str], **kwargs: Any) -> int | str:
       1706│         kwargs["env"] = self.get_temp_environ(environ=kwargs.get("env"))
     → 1707│         return super()._run(cmd, **kwargs)
       1708│
       1709│     def get_temp_environ(

   3  ~/.local/share/pypoetry/venv/lib/python3.10/site-packages/poetry/utils/env.py:1441 in _run
       1439│
       1440│             if input_:
     → 1441│                 output = subprocess.run(
       1442│                     command,
       1443│                     stdout=subprocess.PIPE,

   2  /usr/lib/python3.10/subprocess.py:501 in run
        499│         kwargs['stderr'] = PIPE
        500│
     →  501│     with Popen(*popenargs, **kwargs) as process:
        502│         try:
        503│             stdout, stderr = process.communicate(input, timeout=timeout)

   1  /usr/lib/python3.10/subprocess.py:966 in __init__
        964│                             encoding=encoding, errors=errors)
        965│
     →  966│             self._execute_child(args, executable, preexec_fn, close_fds,
        967│                                 pass_fds, cwd, env,
        968│                                 startupinfo, creationflags, shell,

  FileNotFoundError

  [Errno 2] No such file or directory: 'python'

  at /usr/lib/python3.10/subprocess.py:1842 in _execute_child
      1838│                     else:
      1839│                         err_filename = orig_executable
      1840│                     if errno_num != 0:
      1841│                         err_msg = os.strerror(errno_num)
    → 1842│                     raise child_exception_type(errno_num, err_msg, err_filename)
      1843│                 raise child_exception_type(err_msg)
      1844│
      1845│
      1846│         def _handle_exitstatus(self, sts,

Both machines have the same python apt packages installed. <project-name>-HHTANb4f-py3.10 in /home/<user>/.cache/pypoetry/virtualenvs does not contain the bin directory.

hofrob avatar Aug 13 '22 16:08 hofrob

There are two issues here, one on macOS (which I have been unable to reproduce), and one on Debian-derived distros.

The macOS issue may be a similar packaging issue with Homebrew Python 3.10 as it cannot be reproduced with a Python.org build. That being said, I'd like to keep these separate and keep this issue focused on macOS.

The Debian-derived issue is known and can be worked around with export DEB_PYTHON_INSTALL_LAYOUT=deb -- though we only thought it affected the installer and not Poetry itself. This likely deserves its own issue, and I'd like @abn to take a look at mitigations as he has been the one working on compatibility with broken (distro) Python distributions.

neersighted avatar Aug 14 '22 18:08 neersighted

The same with ubuntu 20.04 LTS and python 3.10.4 (older python versions working OK)

david@david-ThinkPad-T14s-Gen-2i:~$ poetry -V
Poetry version 1.1.14

david-shiko avatar Aug 16 '22 07:08 david-shiko

The canonical place for the Debian/Ubuntu issue is #6371. This issue is for macOS and has yet to be reproduced (reproductions wanted!)

neersighted avatar Sep 02 '22 18:09 neersighted

I had this issue on macOS with beta versions, but I can no longer reproduce it in 1.2.0 release.

If there have been no other reports of this issue, I think this can be closed.

intgr avatar Sep 06 '22 09:09 intgr

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[bot] avatar Mar 01 '24 13:03 github-actions[bot]