-
-
Notifications
You must be signed in to change notification settings - Fork 300
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
Unexpected hatch shell
behavior: PATH prepend is shadowed by shell initialization (due to config.toml shell config mistake)
#1699
Comments
I think I've figured it out. The issue was that my I installed # src/hatch/__init__.py
import pydevd_pycharm
pydevd_pycharm.settrace('localhost', port=33333, stdoutToServer=True, stderrToServer=True) ❯ pipx install -e .
⣯ installing hatch from spec '/Users/dylan/PycharmProjects/hatch'
❯ ~/.local/pipx/venvs/hatch/bin/python -m pip install "pydevd-pycharm~=242.20224.347" Then...
At this point, But notably, the Looking into it further, when def enter_shell(self, name: str, path: str, args: Iterable[str]):
shell_executor = getattr(self.shells, f'enter_{name}', None)
if shell_executor is None:
# Manually activate in lieu of an activation script
with self.safe_activation():
self.platform.exit_with_command([path, *args])
else:
with self.expose_uv(), self.get_env_vars():
shell_executor(path, args, self.virtual_env.executables_directory) ... it appears that Fixing the configuration file resolves this issue. |
While this issue is definitely my own fault, it seems likely enough to happen to others and time-consuming enough to troubleshoot that some kind of quality of life countermeasure might be worthwhile. For example it might be preferable if when
Has something in the behavior here changed in 1.12.0? I wasn't experiencing these issues until I updated Hatch. |
hatch shell
behavior: PATH prepend is shadowed by shell initializationhatch shell
behavior: PATH prepend is shadowed by shell initialization (due to config.toml shell config mistake)
Expected Behavior
When running
hatch shell
, I expect the hatch virtualenvbin
to be prepended to my path, as occurs when sourcing a virtual environment.Problematic Behavior
When running
hatch shell
, the hatch virtualenvbin
is prepended to my path... before my~/.zshrc
runs again and prepends a bunch of other stuff in front of it."Other stuff" includes
asdf
, which means.hatch/<default env>/bin/python
is shadowed by~/.asdf/shims/python
.This results in a ton of breakage unless I manually
source .hatch/<default env>/bin/activate
.Reproduction
I haven't noticed this behavior before, so I'm not sure if this is a regression of some sort.
First, I create a new project:
Heading inside, I check my path. The contents all make sense to me, I can tell where they're all coming from. There is no mysterious source of shell configuration I'm unaware of contributing to the contents of my
PATH
.Now I try to activate the default environment and compare:
Discussion
Hatch seems to be first copying my additions to
PATH
excluding the one set by a plugin (which isasdf
). Then, it appears that my~/.zshrc
ran as usual. Adding anecho SOURCING ZSHRC
to my.zshrc
confirmshatch shell
is creating a new login shell and sourcing it.Running
source ~.hatch/wtf/bin/activate
places/Users/dylan/Projects/wtf/.hatch/wtf/bin
at the top of thePATH
as expected. Notably, this file does not appear to be run automatically at any time byhatch shell
.The text was updated successfully, but these errors were encountered: