Skip to content

zsh: poetry shell doesn't work if space character in .venv path #7244

@dimstunt

Description

@dimstunt
  • Poetry version: Poetry (version 1.3.1)
  • Python version:
Poetry Version: 1.3.1
Python:  3.9.5

Virtualenv
Python:         3.9.5
Implementation: CPython
Path:           /Applications/Dwarf Fortress LMP/LNP/Utilities/Ann2/AnnouncementWindow/.venv
Executable:     /Applications/Dwarf Fortress LMP/LNP/Utilities/Ann2/AnnouncementWindow/.venv/bin/python
Valid:          True

System
Platform:   darwin
OS:         posix
Python:     3.9.5
Path:       /Users/dimstunt/.pyenv/versions/3.9.5
Executable: /Users/dimstunt/.pyenv/versions/3.9.5/bin/python3.9
  • OS version and name: macOS 13.0.1
  • pyproject.toml: any
  • 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

If there is a space in the path to the virtual environment (e.g. when using virtualenvs.in-project=true) the poetry shell command is not executed as expected, because the shlex.quote function wraps that path in single quotes, and when running in zsh, that wrapped path is wrapped in quotes again.

executed:

poetry shell
# Spawning shell within /Applications/Dwarf Fortress LMP/LNP/Utilities/Ann2/AnnouncementWindow/.venv
emulate bash -c '. '/Applications/Dwarf Fortress LMP/LNP/Utilities/Ann2/AnnouncementWindow/.venv/bin/activate''
# emulate: unknown argument Fortress

expected:

poetry shell
# Spawning shell within /Applications/Dwarf Fortress LMP/LNP/Utilities/Ann2/AnnouncementWindow/.venv
emulate bash -c ". '/Applications/Dwarf Fortress LMP/LNP/Utilities/Ann2/AnnouncementWindow/.venv/bin/activate'"

Metadata

Metadata

Assignees

No one assigned

    Labels

    area/shellRelated to `poetry shell`kind/bugSomething isn't working as expected

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions