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 in git bash on Windows broken since 1.2.0 #6495

Closed
Godsmith opened this issue Sep 12, 2022 · 6 comments · Fixed by #6560
Closed

poetry shell in git bash on Windows broken since 1.2.0 #6495

Godsmith opened this issue Sep 12, 2022 · 6 comments · Fixed by #6560
Labels
kind/bug Something isn't working as expected status/triage This issue needs to be triaged

Comments

@Godsmith
Copy link

  • [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.
  • [ x] If an exception occurs when executing a command, I executed it again in debug mode (-vvv option).
  • OS version and name: Windows 11, git 2.33.1.windows.1
  • Poetry version: 1.2.0
  • Link of a Gist with the contents of your pyproject.toml file: Not relevant

Issue

Since poetry 1.2.0, poetry shell does not work on git bash in Windows.

$ poetry shell
Spawning shell within C:\Users\filip\AppData\Local\pypoetry\Cache\virtualenvs\dinrplan-9Ih6xyvL-py3.10
/usr/bin/bash: /K: No such file or directory

Downgrading to 1.1.5 works:

filip@Marwin MINGW64 ~/workspace/python/dinrplan (master)
$ poetry --version
Poetry version 1.1.15

filip@Marwin MINGW64 ~/workspace/python/dinrplan (master)
$ poetry shell
Spawning shell within C:\Users\filip\AppData\Local\pypoetry\Cache\virtualenvs\dinrplan-T1RTjXIi-py3.9

filip@Marwin MINGW64 ~/workspace/python/dinrplan (master)
$ which python
/c/Users/filip/AppData/Local/pypoetry/Cache/virtualenvs/dinrplan-T1RTjXIi-py3.9/Scripts/python

Looking at the code, I believe 57450f2 broke the git bash support.

@Godsmith Godsmith added kind/bug Something isn't working as expected status/triage This issue needs to be triaged labels Sep 12, 2022
@neersighted
Copy link
Member

I think your identification of the point of change is incorrect, but we definitely need to check $SHELL instead of blindly trusting that the user is using CMD/Powershell.

@cbehopkins
Copy link

Is there a suggested workaround to this, besides using powershell when running under windows?

@neersighted
Copy link
Member

poetry shell is just a convenience tool to start a subshell and activate an environment -- you can activate the env yourself with more typing (find the path with poetry env info --path).

@bmarroquin
Copy link
Contributor

The identification point is correct. For windows, we are only considering Powershell or cmd.exe. I'll add a third case to fallback to the previous behavior. The prompt modification won't happen in this situtation.

Here is what shellingham reports

$ .venv/Scripts/python.exe -i
Python 3.10.4 (tags/v3.10.4:9d38120, Mar 23 2022, 23:13:41) [MSC v.1929 64 bit (AMD64)] on win32
Type "help", "copyright", "credits" or "license" for more information.
>>> import shellingham
>>> shellingham.detect_shell()
('bash', 'C:\\Program Files\\Git\\usr\\bin\\bash.exe')

@rcludwick
Copy link

rcludwick commented Oct 6, 2022

@cbehopkins

From previous poetry brokenness, I ended up having a shell alias to do the right thing.

alias pshell='poetry run bash -i'

You can also hardcode which bash you want to run if you want to run.

Keep in mind that at least in my case, on Windows, poetry changed the virtual env it installs to. So if you were using 1.1.15 and upgraded to 1.2.0 or later, you'll want to check to make sure your IDE points to the right virtualenv for your python interpreter.

Copy link

github-actions bot commented Mar 1, 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 1, 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 status/triage This issue needs to be triaged
Projects
None yet
Development

Successfully merging a pull request may close this issue.

5 participants