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

Generated .zoxide.nu has incorrect syntax #661

Closed
SirLarion opened this issue Jan 8, 2024 · 8 comments
Closed

Generated .zoxide.nu has incorrect syntax #661

SirLarion opened this issue Jan 8, 2024 · 8 comments

Comments

@SirLarion
Copy link

I'm using Arch Linux with Nushell 0.88.1. After zoxide init nushell | save -f ~/.zoxide.nu and source ~/.zoxide.nu I get the following:

Error: nu::shell::external_command

  × External command failed
    ╭─[/home/sirlarion/.zoxide.nu:25:1]
 25 │ # Jump to a directory using only keywords.
 26 │ def-env __zoxide_z [...rest:string] {
    · ───┬───
    ·    ╰── did you mean 'let-env'?
 27 │   let arg0 = ($rest | append '~').0
    ╰────
  help: No such file or directory (os error 2)

Then I manually change the offending parts in .zoxide.nu to let-env as recommended by the error but then I get:

Error: nu::parser::expected_keyword

  × Expected keyword.
    ╭─[/home/sirlarion/.zoxide.nu:25:1]
 25 │ # Jump to a directory using only keywords.
 26 │ let-env __zoxide_z [...rest:string] {
    ·                    ────────┬───────
    ·                            ╰── expected =
 27 │   let arg0 = ($rest | append '~').0
    ╰────

This one I was not able to fix.

Environment is:
Kernel: 6.6.10-arch1-1
Terminal: Konsole 23.08.4
Shell: Nushell 0.88.1
Zoxide version 0.9.2

@SirLarion
Copy link
Author

Hmm, looks like the latest templates/nushell.txt does have the correct syntax of def --env rather than def-env. Somewhy I'm still getting the wrong generated code from the latest version

@azzamsa
Copy link

azzamsa commented Jan 9, 2024

Hmm, looks like the latest templates/nushell.txt does have the correct syntax of def --env rather than def-env. Somewhy I'm still getting the wrong generated code from the latest version

What you are seeing is a master, not the latest release of 0.9.2

def-env __zoxide_z [...rest:string] {

To solve the issue you have to 1) compile from source (cargo install --git https://github.com/ajeetdsouza/zoxide), or 2) ask the maintainer to cut a release.

azzamsa added a commit to azzamsa/dotfiles that referenced this issue Jan 9, 2024
Welcome to the club!

However, after several hours of setup. Nushell is not ready for daily usage.

- [nushell: atuin should not always trigger on ⬆️ · Issue #1025 · atuinsh/atuin](atuinsh/atuin#1025)
- [`column_not_found` in Nushell · sxyazi/yazi · Discussion #501](sxyazi/yazi#501)
- [Generated .zoxide.nu has incorrect syntax · Issue #661 · ajeetdsouza/zoxide](ajeetdsouza/zoxide#661)
- [Nushell support · Issue #463 · Schniz/fnm](Schniz/fnm#463)
- Syntax highlighting still requires manual setup.
  - https://github.com/nushell/tree-sitter-nu/blob/main/installation/neovim.md#manual-installation
- nufmt is still very much in beta.
@dvbnrg
Copy link

dvbnrg commented Jan 10, 2024

Hmm, looks like the latest templates/nushell.txt does have the correct syntax of def --env rather than def-env. Somewhy I'm still getting the wrong generated code from the latest version

That fixed everything for me! Thank you good sir!

azzamsa added a commit to azzamsa/dotfiles that referenced this issue Jan 18, 2024
Welcome to the club!

However, after several hours of setup. Nushell is not ready for daily usage.

- [nushell: atuin should not always trigger on ⬆️ · Issue #1025 · atuinsh/atuin](atuinsh/atuin#1025)
- [`column_not_found` in Nushell · sxyazi/yazi · Discussion #501](sxyazi/yazi#501)
- [Generated .zoxide.nu has incorrect syntax · Issue #661 · ajeetdsouza/zoxide](ajeetdsouza/zoxide#661)
- [Nushell support · Issue #463 · Schniz/fnm](Schniz/fnm#463)
- Syntax highlighting still requires manual setup.
  - https://github.com/nushell/tree-sitter-nu/blob/main/installation/neovim.md#manual-installation
- nufmt is still very much in beta.
@ReallySnazzy
Copy link

To be clear for anyone else facing this issue:

If you're using nushell 0.89.0 and inside ~/.zoxide.nu you see def-env, then you can replace the 2 instances of def-env with def --env to resolve the "No such file or directory (os error 2)"

@apraga
Copy link

apraga commented Feb 10, 2024

With @ReallySnazzy fix, I also need to change $rest to ...$rest following the error message. Diff

 # Jump to a directory using only keywords.
-def-env __zoxide_z [...rest:string] {
+def --env __zoxide_z [...rest:string] {
   let arg0 = ($rest | append '~').0
   let path = if (($rest | length) <= 1) and ($arg0 == '-' or ($arg0 | path expand | path type) == dir) {
     $arg0
   } else {
-    (zoxide query --exclude $env.PWD -- $rest | str trim -r -c "\n")
+    (zoxide query --exclude $env.PWD -- ...$rest | str trim -r -c "\n")
   }
   cd $path
 }
 
 # Jump to a directory using interactive search.
-def-env __zoxide_zi  [...rest:string] {
-  cd $'(zoxide query --interactive -- $rest | str trim -r -c "\n")'
+def --env __zoxide_zi  [...rest:string] {
+  cd $'(zoxide query --interactive -- ...$rest | str trim -r -c "\n")'
 }

@ajeetdsouza
Copy link
Owner

Fixed.

@komprimiert
Copy link

replacing def-env with def --env works but as soon as I restart the terminal the zoxide.nu file gets overwritten and when I make the file read-only it cant init zoxide

@ajeetdsouza
Copy link
Owner

Please upgrade your version of zoxide.

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

Successfully merging a pull request may close this issue.

7 participants