wting/autojump

Autojump not working with zsh on Arch Linux when installed with pacman?

prosoitos opened this issue · 9 comments

I ran into the exact same issue as this very old (2012) issue: https://stackoverflow.com/questions/14094848/cannot-source-autojump-script-with-zsh-on-archlinux.

Manual install worked without any problem.


OS: 5.0.10-arch1-1-ARCH
shell: zsh 5.7.1-1

@prosoitos - Can you try the version in the AUR? Works for me with zsh on Arch.

I just gave it a try with quite dramatic results:

  • I installed it from the AUR, tried it, but still got:
zsh: command not found: j
  • So I rebooted and somehow, zsh was totally broken: it would not recognize any command whatsoever, except exit. (bash, reboot, etc. were all unknown. So something failed to load). Since it is my default shell, I had to log in as root to get onto bash to uninstall autojump and get back on my feet.

That said, the problem is probably not the package. It might be that there was a conflict with the package I had manually installed or something else which triggered all this in my quick attempt at testing the new version of autojump.

edit: Yes: I forgot to run ./uninstall.py in the autojump dir to uninstall the version I had before and that is likely the cause. I am not used to installing packages outside pacman... I will do it properly and update in a couple of days when I have time.

I am out of time right now to look at it more deeply. After a clean uninstall of the one I had installed manually, a clean install of the new one from the AUR and making sure to source the right things, hopefully I won't kill zsh again.

(note: I have zsh and Arch up to date)

Pacman can manage your builds for you to avoid this. You are squandering the powers of pacman and makepkg hen you build and install by hand.

Once you installed the distro package for zsh and the AUR package for autojump did it work? Note you do not need to source anything with zsh.

Not sure if I'm necroing this thread. But I'm seeing something very similar.

j doesn't work unless I use it in tmux.

On a console -

❯ j home
zsh: command not found: j

And on the same console after I open tmux -

❯ j home
.

Is this the expected behavior??

This happens with empty .zshrc. I installed autojump through AUR in Arch.

Edit: Resolved by adding source /usr/share/autojump/autojump.zsh to .zshrc. I'm puzzled though why this works on tmux without needing that.

What if you put this in your ~/.zshrc:

[[ -s /etc/profile.d/autojump.zsh ]] && source /etc/profile.d/autojump.zsh

had the exact same issue, can confirm this works

I was also puzzled by this behavior. Turns out that /etc/profile.d/* is not sourced for a non-login shell in Arch; see ArchWiki. Therefore, one has to source /etc/profile.d/autojump.zsh manually, in e.g. ~/.zshrc.

To be more precise, /etc/profile.d/* may have been sourced in a parent login shell (for me it's gnome), and some of its effects may propagate into the child non-login shell. For example, when /etc/profile.d/home-local-bin.sh is sourced it sets the $PATH environment variable, which is exported and inherited by the children. However, although /etc/profile.d/autojump.zsh is (usually) sourced at login, its functions, unlike environment variables, are not exported, and are not passed down to the children. This is also highlighted in ArchWiki. Therefore we have to source it again, manually.

What if you put this in your ~/.zshrc:

[[ -s /etc/profile.d/autojump.zsh ]] && source /etc/profile.d/autojump.zsh

Why do you use -s in the check, not the -e to check if the file exists?