Shell subcommand doesn't bump venv Python in PATH
Is the goal for rye shell to activate a shell with a modified environment that places the venv bin at the top of PATH? If so I'm not sure this is working with SHELL -l.
Using zsh on macos I get the following experience:
With aa559499453a6de2905a40c6ef736e50f6421fa1
test-project on master [?] is 📦 v0.0.1 via 🐍
❯ rye run python -c "import sys; print(sys.executable)"
/Users/chrispryer/github/sandbox/rye/test-project/.venv/bin/python
test-project on master [?] is 📦 v0.0.1 via 🐍
❯ rye shell
Spawning virtualenv shell from /Users/chrispryer/github/sandbox/rye/test-project/.venv
Leave shell with 'exit'
test-project on master [?] is 📦 v0.0.1 via 🐍 (.venv)
❯ which python
/Users/chrispryer/.pyenv/shims/python
With something like sh --init-file .venv/bin/activate
test-project on master [?] is 📦 v0.0.1 via 🐍 took 1m9s
❯ rye run python -c "import sys; print(sys.executable)"
/Users/chrispryer/github/sandbox/rye/test-project/.venv/bin/python
test-project on master [?] is 📦 v0.0.1 via 🐍
❯ rye shell
Spawning virtualenv shell from /Users/chrispryer/github/sandbox/rye/test-project/.venv
Leave shell with 'exit'
sh-3.2$ which python
/Users/chrispryer/github/sandbox/rye/test-project/.venv/bin/python
Yeah it's quite possible that this is not working as intended at the moment. There is unfortunately no way without pexpect or co to initialize a shell with specific environment variables in a portable way.
Yea this is what I've had my eyes on for this https://github.com/rust-cli/rexpect
So looking into this more, I think the shell feature should not exist. It's almost impossible to get right without a ton of hacks, and the only thing it's even trying to do is give you a better syntax to activate a virtualenv. Maybe a better story would be to have something like rye activate-venv and it spits out a command for how to activate the virtualenv?
I'd agree, but from what I can tell a lot of people find it useful. I think it's a UX thing. Like when you use rye you want to defer to rye on how to do things. I wouldn't prioritize this over other stuff though. It's a nice-to-have.
It is probably a good idea to rip shell out for something like rye activate-venv for now. But rye activate-venv reads kind of like it'll activate it. Maybe rye venv-activation or something.