Skip to content

poetry shell doesn't open in $SHELL #1723

@dirn

Description

@dirn
  • I am on the latest Poetry version.
  • I have searched the issues of this repo and believe that this is not a duplicate.
  • If an exception occurs when executing a command, I executed it again in debug mode (-vvv option).

Issue

According to the documentation

The shell command spawns a shell, according to the $SHELL environment variable, within the virtual environment. If one doesn't exist yet, it will be created.

Looking at Poetry's source, however, $SHELL isn't used at all. Instead, os.getpid is called and passed to the detect_shell function in a library called shellingham. If poetry shell is invoked from a subprocess, the pid could be associated with a different shell.

In my particular case, I'm using fish shell and used direnv to automatically load a Poetry shell upon entering the directory. direnv runs everything inside a bash process, causing the Poetry shell to use bash instead of fish.

bash-3.2$ . /Users/dirn/src/playground/testing/.venv/bin/activate
(.venv) bash-3.2$ echo $SHELL
/usr/local/bin/fish
(.venv) bash-3.2$ python -c "import os; print(os.getpid())"
68238
(.venv) bash-3.2$ exit
⋊> ~/s/p/testing python -c "import os; print(os.getpid())"
68242

I'd like to see the behavior match the documentation, but if there are reasons for that not to happen, the documentation should be updated instead.

Metadata

Metadata

Assignees

No one assigned

    Labels

    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