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 shell command does not activate the virtual environment when the user's shell is tsch #2584

Closed
1 task
JnyJny opened this issue Jun 19, 2020 · 2 comments · Fixed by #2583
Closed
1 task
Labels
kind/bug Something isn't working as expected

Comments

@JnyJny
Copy link
Contributor

JnyJny commented Jun 19, 2020

  • [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.

@JnyJny JnyJny added kind/bug Something isn't working as expected status/triage This issue needs to be triaged labels Jun 19, 2020
@JnyJny
Copy link
Contributor Author

JnyJny commented Jun 19, 2020

My workaround until the PR is integrated is to add this to my $HOME/.tcshrc file:

if ( ${?POETRY_ACTIVE} != '0' ) then
    source `poetry env info -p`/bin/activate.csh
endif

This detects a shell with POETRY_ACTIVE and does the right thing.

$ poetry shell
....
$ # good to go

@abn abn closed this as completed in #2583 Jun 19, 2020
@abn abn removed the status/triage This issue needs to be triaged label Sep 25, 2020
Copy link

github-actions bot commented Mar 3, 2024

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 Mar 3, 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
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants