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

zsh: rehash after adding commands #15

Open
kolloch opened this issue Jun 12, 2024 · 2 comments
Open

zsh: rehash after adding commands #15

kolloch opened this issue Jun 12, 2024 · 2 comments

Comments

@kolloch
Copy link

kolloch commented Jun 12, 2024

If you add commands to the current environment, zsh might not pick them up if it has already cached the resolved path of another location.

To reproduce

  1. Use zsh
  2. Have a locally installed JDK
  3. enable some bazel_env via direnv
  4. which jstack --> should output the globally installed one
  5. Add jstack to the bazel_env
  6. which jstack --> still points to the global one, nothing changed
  7. rehash
  8. which jstack --> points to the bazel_env one
@fmeum
Copy link
Collaborator

fmeum commented Jun 13, 2024

We could just run rehash in bazel run //:bazel_env if we detect that we are running in zsh. I don't have much experience with zsh, would you be interested in sending a PR I could review?

@kolloch
Copy link
Author

kolloch commented Jun 15, 2024

I think that the bazel_env command is executed in a subshell, and rehash needs to be executed in the affected shell.

I do think that it probably has to be added to direnv in some way. Or maybe there already is a way via direnv.

Maybe similarly to what has been done for auto-complete here: direnv/direnv#443 (comment)

I'll try to find a nice solution there.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants