ajeetdsouza / zoxide

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

no match found #848

Closed toxic0berliner closed 2 weeks ago

toxic0berliner commented 2 weeks ago

I was looking for a chat as I believe something is wrong on my side but can't figure out what. I always get no match found by zoxide, the db is not growing despite my cd-ing all day long..

my setup :

(andromeda)(root:~)> uname -a && cat /etc/debian_version && zoxide --version && echo -e "fzf :" && fzf --version && bash --version 
Linux andromeda 6.8.4-3-pve #1 SMP PREEMPT_DYNAMIC PMX 6.8.4-3 (2024-05-02T11:55Z) x86_64 GNU/Linux
───────┬─────────────────────────────
       │ File: /etc/debian_version
───────┼─────────────────────────────
   1   │ 12.5
───────┴─────────────────────────────
zoxide 0.9.4
fzf :
0.53.0 (c4a9ccd)
GNU bash, version 5.2.15(1)-release (x86_64-pc-linux-gnu)
Copyright (C) 2022 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>

This is free software; you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law.
(andromeda)(root:~)> which zoxide
/root/.local/bin/zoxide
(andromeda)(root:~)> ls -alh .local/share/zoxide/
Permissions Size User Date Modified Name
.rw-r--r--    12 root 19 Jun 23:42  db.zo

as you can see the db seems stuck at 12 bytes and iis not moving. I can trash the file, change it's permissions, do anything to it it just comes back at 12 bytes and never gorws anything...

This is how it's getting loaded:

(andromeda)(root:~)> cat -r 19:24 .bash_aliases 
───────┬────────────────────────────────────
       │ File: .bash_aliases
───────┼────────────────────────────────────
  19   │ # prefer zoxide
  20   │ if command -v zoxide >/dev/null 2>&1; then
  21 ~ │   #eval "$(zoxide init bash)"
  22 ~ │   eval "$(zoxide init bash --cmd cd --hook prompt)"
  23 ~ │   #alias cd='z'
  24   │ fi
───────┴────────────────────────────────────

which seems to work :

(andromeda)(root:~)> type cd
cd is a function
cd () 
{ 
    __zoxide_z "$@"
}
(andromeda)(root:~)> type cdi
cdi is a function
cdi () 
{ 
    __zoxide_zi "$@"
}

I'm running inside an lxc on my pve but that shouldn't change anything I believe.

I've "installed" zoxide using apt-get before, it was an old version and was broken as well with the same issue, so I switched to the latest I got using eget (downloads & extracts the latest musl binary from github...)

I've found I had export PATH=$PATH:~/.local/bin that was causing me issues in my .bashrc but I changed it to $HOME instead of ~ but it didn't fix my issue with zoxide... now PATH is fine :

(andromeda)(root:~)> echo $PATH
/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/root/.dotfiles/bin/:/root/.local/bin

Finally I'm stuck with this every time :

(andromeda)(root:~)> cdi
zoxide: no match found
(ERROR)-(Exit Code 1)-(General error)
(andromeda)(root:~)> cd somewhere I went
zoxide: no match found
(ERROR)-(Exit Code 1)-(General error)

any help finding out why or getting some logs from zoxide would be helpful !

Thanks in advance for your kind help

toxic0berliner commented 2 weeks ago

I found my issue...

Seems zoxide needs a hook in $PS1.... I found out in https://github.com/ajeetdsouza/zoxide/issues/270 ...

And my bashrc was rewriting PS1 after loading zoxide...

I've changed it to load zoxide last... And now it seems it's starting to work... the db is growing...

Probably someone might want to document the fact that one shall it needs PS1 ? whell stangely I don't see any reference to zoxide in my PS1 but now it works... This is my PS1 for the record \[\033[1;30m\](andromeda)(\[\033[0;31m\]\u\[\033[1;30m\]:\[\033[0;33m\]\w\[\033[1;30m\])\[\033[0;31m\]>\[\033[0m\]

Maybe something else was blocking ? I'd like to find out cause I'd like to put zoxide back in my .bash_aliases instead of at the end of .bashrc..

Or maybe it's the way I invoked my .bash_aliases ?

(andromeda)(root:~)> cat -r 146:148 .bashrc
───────┬────────────────────────────────────
       │ File: .bashrc
───────┼────────────────────────────────────
 146   │ if [ -f ~/.bash_aliases ]; then
 147   │     . ~/.bash_aliases
 148   │ fi
───────┴────────────────────────────────────
ajeetdsouza commented 2 weeks ago

zoxide does require $PS1 to function, as you've discovered. That is the reason it needs to be called at the end of your config file. It's been mentioned in the README too:

image
toxic0berliner commented 2 weeks ago

Oups, should have read better sorry and thanks @ajeetdsouza !