Skip to content

poetry shell command does not activate the virtual environment when the user's shell is tsch #2584

@JnyJny

Description

@JnyJny
  • [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.
  • If an exception occurs when executing a command, I executed it again in debug mode (-vvv option).
  • OS version and name: macOS 10.15.5
  • Poetry version: 1.0.9
  • Link of a Gist with the contents of your pyproject.toml file: pyproject.toml

Issue

I recently switched back to tcsh from bash and found that poetry shell now fails to activate the python virtual environment.

ejo@ufo:blynclight -> poetry --version
Poetry version 1.0.9
ejo@ufo:blynclight -> poetry shell
Spawning shell within /Users/ejo/Library/Caches/pypoetry/virtualenvs/blynclight-JhnzrnPE-py3.7
ejo@ufo:blynclight -> . /Users/ejo/Library/Caches/pypoetry/virtualenvs/blynclight-JhnzrnPE-py3.7/bin/activate
/usr/bin/.: Permission denied.
ejo@ufo:blynclight -> echo $shlvl 
2

The $shlvl variable indicates that a new shell was invoked, but the errors indicate that the virtual environment was not properly activated.

It appears that poetry shell is attempting to use the bash method of activating the virtual environment which does not work for tcsh (as expected).

Inspection of the two methods:

  • poetry.utils.shell.Shell._get_activate_script
  • poetry.utils.shell.Shell._get_source_command

show explicit checks for csh and fish but not tcsh.

When the user's shell is tcsh, both of those methods will mis-identify the shell as bash and it all ends badly.

I submitted PR #2583 which expands the explicit checking done in those methods to include tcsh and lumps handling for csh and tcsh together.

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