ajeetdsouza / zoxide

A smarter cd command. Supports all major shells.
MIT License
20.54k stars 523 forks source link

Zoxide binary not found when opening new session #708

Closed MaximSrour closed 4 months ago

MaximSrour commented 5 months ago

I'm running Ubuntu Server 22.04.3 and have installed Zoxide using the curl command,

curl -sS https://raw.githubusercontent.com/ajeetdsouza/zoxide/main/install.sh | bash
source ~/.bashrc

If I do this, I can then use the z commands just fine. However, when I close the terminal completely and then SSH back in using a completely new session, the eval command in the bashrc (eval "$(zoxide init --cmd cd bash)") gives the following message:

Command 'zoxide' not found, but can be installed with:
sudo apt install zoxide

The z commands seem to still work just fine, however this is a little annoying and I don't want to pipe it to /dev/null in case there is something else that goes wrong. Any idea what the cause is?

sudhackar commented 4 months ago

The binary gets downloaded to $HOME/.local/bin https://github.com/ajeetdsouza/zoxide/blob/e55e0b27e27930ab8af81999a91b56cf0cd6ff6f/install.sh#L50 Can you check its still there? Is this on your PATH or not?

echo $PATH and which zoxide should give you this context

fendis0709 commented 4 months ago

I'm also facing the same problem. After executing export PATH=$HOME/.local/bin and open new terminal session, command zoxide is not found.

Here's my solution (using .zshrc):

  1. Open text editor, e.g. nano
nano ~/.zshrc
  1. Add this command in the file .zshrc
export PATH=$HOME/.local/bin:$PATH
eval "$(zoxide init --cmd cd zsh)"
  1. Load the new .zshrc config
source ~/.zshrc
  1. Check zoxide command
zoxide --version

Now, you should able to execute Zoxide command. If you're using bashrc, you should make a little bit adjustment to edit file ~/.bashrc and execute source ~/.bashrc.

If you want to check the PATH, you can execute echo $PATH. image

aidandeli commented 4 months ago

I was also facing that problem. After adding the line mentioned by @fendis0709, I no longer get the message about Zoxide missing, but I am now facing a different problem. I've outlined the different problem here: https://github.com/ajeetdsouza/zoxide/issues/723

ajeetdsouza commented 4 months ago

That's the correct solution - export PATH=$HOME/.local/bin:$PATH needs to be added to the .zshrc file before initializing zoxide. The install script usually warns about this: https://github.com/ajeetdsouza/zoxide/blob/e55e0b27e27930ab8af81999a91b56cf0cd6ff6f/install.sh#L71