[X] I agree to follow this project's Code of Conduct
What happened?
Poetry is a python package manager. While inside a poetry project you should be able to run the poetry shell command and get a new shell that has the python virtualenv activated (the $VIRTUAL_ENV enviroment variable should be set correctly). This does not seem to happen when using recent versions of oh-my-posh. The new shell does spawn, but the python virtualenv is not active inside it.
I was able to bisect the issue to commit 28817bae481dfc3d715aa8aa4c1b6cda7d903e0f.
I came up with a minimal docker setup to reproduce it. This is the Dockerfile:
FROM golang:1.23-bookworm AS builder
WORKDIR /test
RUN set -eux; \
git clone https://github.com/JanDeDobbeleer/oh-my-posh.git; \
cd oh-my-posh/src; \
git checkout 28817bae481dfc3d715aa8aa4c1b6cda7d903e0f; \
# git checkout @~1; \
go build
FROM python:3.12-bookworm
WORKDIR /test
COPY --from=builder /test/oh-my-posh/src/src /test/oh-my-posh
RUN set -eux; \
echo 'eval "$(/test/oh-my-posh init bash)"' >> ~/.bashrc; \
pip install poetry; \
poetry init -q; \
poetry add fastapi
ENTRYPOINT ["/usr/bin/tail", "-f", "/dev/null"]
You can copy that somewhere (review it first, of course), then in that directory run these commands:
You will be dropped at an oh-my-posh prompt. Run poetry shell. That will spawn the new shell that's supposed to have the virtualenv active. But if you type env | grep VIRTUAL_ENV that won't print anything. The environment variable is not defined. Also, if you start a python repl with python3 -i and at the >>> prompt type from fastapi import FastAPI you will get a ModuleNotFoundError: No module named 'fastapi' error.
Now, if you get out of the docker container, delete it (with docker rm -f test-posh), un-comment the git checkout @~1 line from the Dockerfile (to build based on the previous commit) and start over, you'll have a different experience: $VIRTUAL_ENV will be defined and will contain a path like /root/.cache/pypoetry/virtualenvs/test-swbZ_4R8-py3.12, and running from fastapi import FastAPI in python will not cause an error.
I should also mention that the "regular" way of creating and activating python virtual enviroments (python3 -m venv venv; source venv/bin/activate) works fine.
Code of Conduct
What happened?
Poetry is a python package manager. While inside a poetry project you should be able to run the
poetry shell
command and get a new shell that has the python virtualenv activated (the$VIRTUAL_ENV
enviroment variable should be set correctly). This does not seem to happen when using recent versions of oh-my-posh. The new shell does spawn, but the python virtualenv is not active inside it.I was able to bisect the issue to commit 28817bae481dfc3d715aa8aa4c1b6cda7d903e0f.
I came up with a minimal docker setup to reproduce it. This is the
Dockerfile
:You can copy that somewhere (review it first, of course), then in that directory run these commands:
You will be dropped at an oh-my-posh prompt. Run
poetry shell
. That will spawn the new shell that's supposed to have the virtualenv active. But if you typeenv | grep VIRTUAL_ENV
that won't print anything. The environment variable is not defined. Also, if you start a python repl withpython3 -i
and at the>>>
prompt typefrom fastapi import FastAPI
you will get aModuleNotFoundError: No module named 'fastapi'
error.Now, if you get out of the docker container, delete it (with
docker rm -f test-posh
), un-comment thegit checkout @~1
line from theDockerfile
(to build based on the previous commit) and start over, you'll have a different experience:$VIRTUAL_ENV
will be defined and will contain a path like/root/.cache/pypoetry/virtualenvs/test-swbZ_4R8-py3.12
, and runningfrom fastapi import FastAPI
in python will not cause an error.Theme
default
What OS are you seeing the problem on?
Linux, macOS
Which shell are you using?
bash, zsh
Log output