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

Abortion of poetry shell if it doesn't manage to find shell files #9269

Closed
dcguim opened this issue Apr 3, 2024 · 3 comments
Closed

Abortion of poetry shell if it doesn't manage to find shell files #9269

dcguim opened this issue Apr 3, 2024 · 3 comments
Labels
kind/feature Feature requests/implementations status/triage This issue needs to be triaged

Comments

@dcguim
Copy link

dcguim commented Apr 3, 2024

Issue Kind

Change in current behaviour

Description

Currently in poetry 1.8.2, and I am using zshell (default on macOS). My zshell configuration is slightly different than usual, as I keep my dot-z-shell files in a separate infra folder, as I like to version them, in my $HOME, I and a single .zshenv file:

ZDOTDIR=$HOME/work/infra/.zsh
source $ZDOTDIR/.zshenv

When I try to enter into a virtualenv with $ poetry shell I get the following messages:

Using python3 (3.11.8)
Spawning shell within /Users/dguim/Library/Caches/pypoetry/virtualenvs/private-gpt-8E1Wl_zS-py3.11
/etc/zshrc:7: command not found: locale
/etc/zshrc_Apple_Terminal:104: command not found: mkdir
env: bash: No such file or directory

So poetry shell is trying to access the system-wide zshell files at /etc/ (I believe this is because it couldn't find the zshell files in my home directory) and in this process it is truncating my $PATH as the the values of $PATH in the environment do not contain the usual paths, such as /usr/local/bin, /usr/bin, /bin, /usr/sbin, ...

Moreover, I was about to ask if it would be desirable to implement a functionality for poetry bash that inspects the shell files available, say at $HOME and if it can't find any shell files, it aborts the command altogether with the message "Please provide argument '--path' for locating your shell files"

Impact

$ poetry shell command will have limited functionality when user keep their shell files in non-obvious places.

Workarounds

Looking in the documentation I tried using VIRTUAL_ENV_DISABLE_PROMPT=1. Of course I could just activate the shell on my own source $(poetry env info --path)/bin/activate, but I am not sure if poetry bash is doing some other nice things that I want, or if it is just activating the shell.

@dcguim dcguim added kind/feature Feature requests/implementations status/triage This issue needs to be triaged labels Apr 3, 2024
@dimbleby
Copy link
Contributor

dimbleby commented Apr 3, 2024

if you want to dig into it then the activation code starts here

imo poetry shell is a mistake and sourcing the venv activation script yourself is just better. More discussion eg in python-poetry/poetry-plugin-shell#18

@dcguim dcguim closed this as completed Apr 5, 2024
@dcguim
Copy link
Author

dcguim commented Apr 5, 2024

I will just alias poetry bash to source $(poetry env info --path)/bin/activate this should do for now.

Copy link

github-actions bot commented May 6, 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 May 6, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
kind/feature Feature requests/implementations status/triage This issue needs to be triaged
Projects
None yet
Development

No branches or pull requests

2 participants