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

[bug]: __zoxide_cd:cd:2: no such file or directory: foo #37

Closed
3 tasks done
ruimarinho opened this issue Mar 17, 2023 · 13 comments · Fixed by #38
Closed
3 tasks done

[bug]: __zoxide_cd:cd:2: no such file or directory: foo #37

ruimarinho opened this issue Mar 17, 2023 · 13 comments · Fixed by #38
Assignees
Labels
bug 🐞 Inconsistencies or issues which will cause a problem for users or implementors. resolved ☑️ The issue has been fixed and is therefore considered resolved.

Comments

@ruimarinho
Copy link

ruimarinho commented Mar 17, 2023

Environment

Device: apple | darwin22.0 | arm64 | Shell: /bin/zsh | -zsh | zsh-5.8.1-0-g1a490c7 Zi: 75929e8f4425761a64591d0f6c23dbb0c64261fc | zoxide v0.9.0

Reproduction steps

  1. Load z-shell/zoxide:
    zi has'zoxide' wait lucid for atload="function z() { __zoxide_z \"\$@\" }" \
    z-shell/zsh-zoxide
  1. Attempt to use x or z (in this case). For every directory, __zoxide_cd:cd:2: no such file or directory: <directory> is returned.

Expected behavior

x or z<SPACE><DIRECTORY> correctly hooks into zoxide.

Current behavior

For every directory, __zoxide_cd:cd:2: no such file or directory: <directory> is returned.

Code snippet

zi has'zoxide' wait lucid for atload="function z() { __zoxide_z \"\$@\" }" \
  z-shell/zsh-zoxide

Additional information

Using zsh-zoxide in isolation (no other plugins) results in the same behaviour.

It seems like zi is resetting $chpwd_functions because if I echo that once the shell is loaded, only @zi-scheduler is listed there.

if [[ ${precmd_functions[(Ie)__zoxide_hook]:-} -eq 0 ]] && [[ ${chpwd_functions[(Ie)__zoxide_hook]:-} -eq 0 ]]; then
    chpwd_functions+=(__zoxide_hook)
fi

...yet:

❯ echo $chpwd_functions
@zi-scheduler

Self-service

  • I'd be willing to address this documentation request myself.

Have you read the Contributing Guidelines?

Are you familiar with the Contributor Covenant Code of Conduct?

Contact Details

No response

@ruimarinho ruimarinho added bug 🐞 Inconsistencies or issues which will cause a problem for users or implementors. triage 📑 The issue is awaiting investigation. labels Mar 17, 2023
@ruimarinho ruimarinho changed the title [bug]: __zoxide_cd:cd:2: no such file or directory: foo [bug]: __zoxide_cd:cd:2: no such file or directory: foo Mar 17, 2023
@ss-o
Copy link
Member

ss-o commented Mar 18, 2023

Hi @ruimarinho 👋

Thank you for opening the issue, unfortunately, I am unable to reproduce the issue, however, I have attempted on linux-gnu as I am currently unable to initiate the darwin22.0 environment. I will get back to this whenever possible.

The code snippet you provided has a redundant ice-modifier atload:

atload="function z() { __zoxide_z \"\$@\" }"

This plugin automatically hooks x and xi for Zi, this behavior can be changed by setting prefix variable _ZO_CMD_PREFIX:

Variable Description Default
_ZO_CMD_PREFIX Set variable to preferred prefix Zi: x, other: z

Example to set c, ci

zi has'zoxide' wait lucid for atinit="_ZO_CMD_PREFIX=c" \
  z-shell/zsh-zoxide

Note: The z is not compatible with Zi as it is linked with zi which is conflicting function when using Zi.

Could you please confirm that the issue persists when the redundant ice-modifier is not used, and could you try another install method? This would help me to identify the issue.

@ruimarinho
Copy link
Author

Hi @ss-o,

That ice modifier enables z in favor of x as it's in the memory of most us nowadays. Instead of changing the prefix to z which would break compatibility with zi, I'm just aliasing that one.

If I use the traditional install method without the ice modifier, I get this instead:

❯ x test
__zoxide_cd:cd:2: no such file or directory: test
❯ echo $chpwd_functions
@zi-scheduler

If I manually eval the output of:

eval "$(zoxide init zsh)"

I get:

❯ echo $chpwd_functions
__zoxide_hook @zi-scheduler

It's something to do with the async integration for sure.

@ruimarinho
Copy link
Author

I'm trying to narrow the problem and I'm getting closer, but I still don't know what causes the buggy outcome.

Calling @zsh-eval-cache zoxide init --cmd $_ZO_CMD_PREFIX zsh with ZEC_DISABLED=1 ZEC_DEBUG=1 results in evaling zoxide init --cmd x zsh which theoretically would make everything work again, but it doesn't.

This eliminates the scenario where a cached eval could be causing issues. I'm wondering if it's a bug in the plugin framework of zi? That @zi-scheduler is suspicious..

@ruimarinho
Copy link
Author

If I copy the output of the cached eval and manually load it via a snippet, it also works:

zi ice wait lucid
zi snippet /opt/dotfiles/zi/snippets/zoxide.zsh

@ss-o
Copy link
Member

ss-o commented Mar 18, 2023

Thank you for your detailed response, I am working on this now.

Could you please provide the output of the following:

  • zi report z-shell/zsh-zoxide
  • setopt ksh_option_print && setopt

The @zi-scheduler distributes the work over time and allows activation of the keyboard in between the snippets/plugins. For example:

My current state:

~ echo $chpwd_functions
@zi-scheduler

State with the plugin which sets $chpwd_function:

~ echo $chpwd_functions
→auto-lsd @zi-scheduler

Manually executed →auto-lsd @zi-scheduler is the same as command lsd $lsd_params which is the expected behavior (which →auto-lsd).

Snippet used for the example above:

zi-turbo '0a' for \
  binary from"gh-r" sbin \
    ajeetdsouza/zoxide \
  has'lsd' atinit'AUTOCD=1' \
    z-shell/zsh-lsd \
  has'zoxide' \
    z-shell/zsh-zoxide

Summarized the snippet in concern:

echo $chpwd_functions
__zoxide_hook @zi-scheduler

The __zoxide_hook @zi-scheduler should behave same as command zoxide add -- "$(__zoxide_pwd)" - (which __zoxide_hook).

@ss-o
Copy link
Member

ss-o commented Mar 18, 2023

If I copy the output of the cached eval and manually load it via a snippet, it also works:

zi ice wait lucid
zi snippet /opt/dotfiles/zi/snippets/zoxide.zsh

It is a good clue for tracing. Could you confirm that snippet:

zi has'zoxide' wait lucid for \
  atload="function z() { __zoxide_z \"\$@\" }" \
    z-shell/zsh-zoxide

Fails when:

  • xEnter
  • xSpace$HOMEEnter

Branch auto_pushd may have a positive effect and can be tested using the ver ice-modifier:

zi has'zoxide' ver'auto_pushd' wait lucid for \
  atload="function z() { __zoxide_z \"\$@\" }" \
    z-shell/zsh-zoxide

@ruimarinho
Copy link
Author

With:

zi has'zoxide' wait lucid for \
  atload="function z() { __zoxide_z \"\$@\" }" \
    z-shell/zsh-zoxide

When I do:

  • x <Enter>
  • x <Space>$HOME<Enter>

...both are successful.

However, I can check the zoxide hook wasn't called because zoxide does not record the chpwd:

❯ zoxide query $HOME
zoxide: no match found

I can use x to cd:

❯ x /tmp

/tmp

..but only if I give it an actual path.

❯ x tmp
__zoxide_cd:cd:2: no such file or directory: tmp

~

This should have worked but it doesn't.

Using the auto_pushd branch yields no change:

❯ zi report z-shell/zsh-zoxide
Report for z-shell/zsh-zoxide plugin
------------------------------------
Source zsh-zoxide.plugin.zsh (reporting enabled)
Autoload .zsh-prepare-zoxide with options -U -z
Autoload .zi-prepare-zoxide with options -U -z
Autoload @zsh-eval-cache with options -U -z
Saving `compdef -d x' for replay
Saving `compdef -d xi' for replay
Saving `compdef __zoxide_z_complete x' for replay

- Functions created:
@zsh-eval-cache __zoxide_cd
__zoxide_hook __zoxide_pwd
__zoxide_z __zoxide_z_complete
__zoxide_zi x
xi

- Variables added or redefined:
_ZO_CMD_PREFIX [ "" -> scalar ]
_ZO_DATA_DIR [ "" -> scalar-export ]
_ZO_MAXAGE [ "" -> scalar ]
_ZO_FZF_OPTS [ "" -> scalar ]
_ZO_RESOLVE_SYMLINKS [ "" -> scalar ]
_ZO_ECHO [ "" -> scalar ]
_ZO_EXCLUDE_DIRS [ "" -> scalar ]

- Completions:
_zoxide [enabled]
_zoxide [enabled]


~
❯ setopt ksh_option_print && setopt
noaliases             off
aliasfuncdef          off
allexport             off
noalwayslastprompt    off
alwaystoend           off
appendcreate          off
noappendhistory       off
autocd                off
autocontinue          off
noautolist            off
noautomenu            off
autonamedirs          off
noautoparamkeys       off
noautoparamslash      off
autopushd             off
noautoremoveslash     off
autoresume            off
nobadpattern          off
nobanghist            off
nobareglobqual        off
bashautolist          off
bashrematch           off
nobeep                off
nobgnice              off
braceccl              off
bsdecho               off
nocaseglob            off
nocasematch           off
cbases                off
cdablevars            off
cdsilent              off
chasedots             off
chaselinks            off
nocheckjobs           off
nocheckrunningjobs    off
noclobber             off
combiningchars        on
completealiases       off
completeinword        off
continueonerror       off
correct               off
correctall            off
cprecedences          off
cshjunkiehistory      off
cshjunkieloops        off
cshjunkiequotes       off
cshnullcmd            off
cshnullglob           off
nodebugbeforecmd      off
dvorak                off
emacs                 off
noequals              off
errexit               off
errreturn             off
noevallineno          off
noexec                off
extendedglob          off
extendedhistory       on
noflowcontrol         off
forcefloat            off
nofunctionargzero     off
noglob                off
noglobalexport        off
noglobalrcs           off
globassign            off
globcomplete          off
globdots              off
globstarshort         off
globsubst             off
nohashcmds            off
nohashdirs            off
hashexecutablesonly   off
nohashlistall         off
histallowclobber      off
nohistbeep            off
histexpiredupsfirst   on
histfcntllock         off
histfindnodups        off
histignorealldups     on
histignoredups        off
histignorespace       on
histlexwords          off
histnofunctions       off
histnostore           off
histreduceblanks      on
nohistsavebycopy      off
histsavenodups        on
histsubstpattern      off
histverify            off
nohup                 off
ignorebraces          off
ignoreclosebraces     off
ignoreeof             off
incappendhistory      on
incappendhistorytime  off
interactive           on
interactivecomments   off
ksharrays             off
kshautoload           off
kshglob               off
kshoptionprint        on
kshtypeset            off
kshzerosubscript      off
nolistambiguous       off
nolistbeep            off
listpacked            off
listrowsfirst         off
nolisttypes           off
localloops            off
localoptions          off
localpatterns         off
localtraps            off
login                 on
longlistjobs          off
magicequalsubst       off
mailwarning           off
markdirs              off
menucomplete          off
monitor               on
nomultibyte           off
nomultifuncdef        off
nomultios             off
nonomatch             off
nonotify              off
nullglob              off
numericglobsort       off
octalzeroes           off
overstrike            off
pathdirs              off
pathscript            off
pipefail              off
posixaliases          off
posixargzero          off
posixbuiltins         off
posixcd               off
posixidentifiers      off
posixjobs             off
posixstrings          off
posixtraps            off
printeightbit         off
printexitvalue        off
privileged            off
promptbang            off
nopromptcr            on
nopromptpercent       off
nopromptsp            off
promptsubst           on
pushdignoredups       off
pushdminus            off
pushdsilent           off
pushdtohome           off
rcexpandparam         off
rcquotes              off
norcs                 off
recexact              off
rematchpcre           off
restricted            off
rmstarsilent          off
rmstarwait            off
sharehistory          off
shfileexpansion       off
shglob                off
shinstdin             on
shnullcmd             off
shoptionletters       off
noshortloops          off
shwordsplit           off
singlecommand         off
singlelinezle         off
sourcetrace           off
sunkeyboardhack       off
transientrprompt      off
trapsasync            off
typesetsilent         off
nounset               off
verbose               off
vi                    off
warncreateglobal      off
warnnestedvar         off
xtrace                off
zle                   on

@ss-o
Copy link
Member

ss-o commented Mar 18, 2023

I have found a problem, currently testing 👍

I will update on this as soon as possible

@ruimarinho
Copy link
Author

I'm around so I think I'll be able to provide quick feedback :) thanks a lot!

@ss-o ss-o linked a pull request Mar 18, 2023 that will close this issue
@ss-o
Copy link
Member

ss-o commented Mar 18, 2023

Thank you for pointing this out! 🥇 The PR #38 is ready for your judgment 👍

Snippet for testing #38:

zi has'zoxide' ver'auto_pushd' for atload="function z() { __zoxide_z \"\$@\" }" \
z-shell/zsh-zoxide

@ss-o ss-o added resolved ☑️ The issue has been fixed and is therefore considered resolved. and removed triage 📑 The issue is awaiting investigation. labels Mar 18, 2023
@ruimarinho
Copy link
Author

Yep, works perfectly now. Fantastic!

@ss-o ss-o closed this as completed in #38 Mar 18, 2023
ss-o added a commit that referenced this issue Mar 18, 2023
correctly assign parameters

Signed-off-by: Sall <sall@w-ss.io>
@ss-o
Copy link
Member

ss-o commented Mar 18, 2023

Hopefully, the @zi-scheduler is not suspicious anymore 🧙‍‍♀️ You might like its features ✨ 🙇‍‍♂️

@ss-o
Copy link
Member

ss-o commented May 18, 2023

This issue has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.

@z-shell z-shell locked and limited conversation to collaborators May 18, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
bug 🐞 Inconsistencies or issues which will cause a problem for users or implementors. resolved ☑️ The issue has been fixed and is therefore considered resolved.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants