-
Notifications
You must be signed in to change notification settings - Fork 2.3k
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 does not activate virtual env #9640
Comments
Plainly poetry is activating the environment. Perhaps you have code in your .bashrc or whatever that always puts pyenv at the front of the path. Whatever is happening is going to be local to your system, you will likely have to figure it out for yourself. |
I'm running into the same issue. Copying the activate command that's printed and running it properly activates the env. Interestingly, this same behavior exists when using the vscode terminal (which I don't believe uses poetry shell). |
Does not appear to apply to @melikbugra, but for those of you that use Oh My Posh and see this issue, I have a "solution". I will spare you the long debugging process, but the issue appears related to this issue: JanDeDobbeleer/oh-my-posh#2451 (comment)
So, if you use oh-my-posh use version v7.94.1. If you are using something else, it might make more sense just to use |
Note that I see the issue with newer versions of oh-my-posh on a VM using Ubuntu 22.04, no WSL2 involved, in addition to running it in Ubuntu 20.04 with WSL2 (with an EXT4 formatted VHD). |
@neel-m are you suggesting this is a regression in oh-my-posh? I'm on version |
yes, there is a long discussion in oh-my-posh (linked above) that is relevant. Does not appear to be a bug in oh-my-posh but likely something in its long tail of dependencies. |
That will get you the version before the change that made things not work. Note make sure you turn off oh-my-posh before you do the above or it can be challenging to get things done 😃 There has also been a change in the format of the themes so your new format theme might not be compatible with the old oh-my-posh code. |
@neel-m there has to be a newer version right before the latest regression though, no? |
The regression occurred over 2 years ago. It is NOT a regression in oh-my-posh (there was no code change in the repo that caused this issue). There was some investigation into which dependency might have caused this, but it only seemed to impact WSL2. It got a lot of attention, but I didn't see any solution and the problem still occurs with the current version of oh-my-posh. Since I use (and love) oh-my-posh I might take some time to see if I can figure out something that resolves it, but right now the workaround is to use a very old version of oh-my-posh (which is what I was doing until I updated in the last month and discovered the issue) or manually run the activation script. Neither one is a bad solution. If you are using something that needs the newer version of oh-my-posh, create an alias to make running the activation script easier (assuming you are using linux, I am not using this with PowerShell, not sure what works there). |
Ah I see where the confusion is. I'm assuming that the issue you linked to was resolved since it was first raised, and that something new must have happened, because this was working fine for me until recently. |
I found a solution on my setup. Too specific but might work for someone else. I had some lines related to docker configuration in my .bashrc, I deleted them and the issue is fixed. I don't know why, but it just worked :) |
|
It was for me too, but then I recently updated oh-my-posh. I didn't realize that is likely when my problems started. I had been using a very old version of oh-my-posh from near the beginning, which had been working fine for years. |
Ah, I gotcha. Yeah I've been doing an update at max a few weeks after each release comes out and is announced in the shell. At some point I'll try to binary search my way to a working version lol |
no need, it has already been done, use version 7.94.1 |
I did more research and know a little more. It seems that on my VM (with my theme) the newer version of oh-my-posh takes about 5 seconds to be ready. If I put a time.sleep(6) before the c.sendline() in shell.py (in the utils folder) the activation works, but there is some garbage displayed. If I use a combination of sendline() and expect() I can get it to wait long enough such that the new shell accepts the activate command. This is, of course, messy and not clearly a good idea, but does point to this being something strange with the newer versions of oh-my-posh in this special case. |
Filed this issue with OMP: JanDeDobbeleer/oh-my-posh#5713 to track the underlying issue (which does not seem to be related to Poetry). |
JanDeDobbeleer resolved the issue I filed on oh-my-posh: If you are using a recent release of OMP, you need to disable the upgrade notice (even if you are using the latest version). |
I would say this issue is resolved. |
@neel-m thanks for putting in the effort! TL;DR: Setting |
Thanks for the ideas! |
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. |
Description
When I run poetry shell command, it does not activate the virtual environment although it says so.
I am on WSL2 Ubuntu 24.04
Workarounds
Activating the venv manually by sourcing it, works.
Poetry Installation Method
pipx
Operating System
WSL2 Ubuntu 24.04
Poetry Version
1.8.3
Poetry Configuration
Python Sysconfig
Example pyproject.toml
Poetry Runtime Logs
The text was updated successfully, but these errors were encountered: