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

eval of shell-hooks command prints errors if cache has been cleared #252

Open
MatthewDolan opened this issue Apr 9, 2022 · 0 comments
Open

Comments

@MatthewDolan
Copy link

The standard shell-hooks command is eval "$(test -x $HOME/bin/hermit && $HOME/bin/hermit shell-hooks --print --zsh)"
https://cs.github.com/cashapp/hermit/blob/18405e856a5c566d5e5f8d0b8b0f954ce192aec0/shell/zsh.go#L43

This command prints errors when it's run if the cache directory has been deleted.

> rm -rf ~/.cache/hermit
> eval "$(test -x $HOME/bin/hermit && $HOME/bin/hermit shell-hooks --print --zsh)"
zsh: command not found: Creating
zsh: command not found: Downloading
zsh: command not found: Hermit
zsh: command not found: Removing
zsh: command not found: Hermit
zsh: command not found: See      

This is because the shell-hooks --print command prints some extraneous information if the cache has been deleted.

> rm -rf ~/.cache/hermit
> $HOME/bin/hermit shell-hooks --print --zsh
Creating /home/codespace/.cache/hermit/pkg/hermit@stable
Downloading https://github.com/cashapp/hermit/releases/download/stable/hermit-linux-amd64.gz to /home/codespace/.cache/hermit/pkg/hermit@stable/hermit
Hermit installed as /home/codespace/.cache/hermit/pkg/hermit@stable/hermit
Removing the previous /home/codespace/bin/hermit-stable
Hermit is installed as /home/codespace/bin/hermit

change_hermit_env() {
...

I have a bit of a hacky solution which is to run hermit version > /dev/null first which forces the install before running the shell-hooks command.

eval "$(test -x $HOME/bin/hermit &&  $HOME/bin/hermit version > /dev/null && $HOME/bin/hermit shell-hooks --print --zsh)"

It might worth making a less hacky / more permanent fix (there are a few options I can think of but I am not confident enough on which is the right fix).

(For context, the reason I came across this was that I recently updates my dotfiles install.sh to automatically install hermit.

MatthewDolan/dotfiles@e472587

Mostly, it worked perfectly. Except that there is a bug when hermit tries to print shell-hooks if the cache has been cleared.)

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

1 participant