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

Error with nushell 0.83.0 #595

Closed
yanecc opened this issue Jul 26, 2023 · 12 comments
Closed

Error with nushell 0.83.0 #595

yanecc opened this issue Jul 26, 2023 · 12 comments

Comments

@yanecc
Copy link

yanecc commented Jul 26, 2023

The project is not well-adapted to the latest version of nushell, version 0.83.0, and it displays the following error:

Error: nu::parser::input_type_mismatch

  × Command does not support string input.
    ╭─[C:\Users\Sunrise\.zoxide.nu:27:1]
 27 │   let arg0 = ($rest | append '~').0
 28 │   let path = if (($rest | length) <= 1) and ($arg0 == '-' or ($arg0 | path expand | path type) == dir) {
    ·                           ───┬──
    ·                              ╰── command doesn't support string input
 29 │     $arg0
    ╰────
@asim215
Copy link

asim215 commented Jul 26, 2023

Solution is following:
($rest | str length).0 <= 1
I also changed everywhere:
from let-env x to $env.x

# Initialize hook to add new entries to the database.
if (not ($env | default false __zoxide_hooked | get __zoxide_hooked)) {
  $env.__zoxide_hooked = true
  $env.config = ($env | default {} config).config
  $env.config = ($env.config | default {} hooks)
  $env.config = ($env.config | update hooks ($env.config.hooks | default {} env_change))
  $env.config = ($env.config | update hooks.env_change ($env.config.hooks.env_change | default [] PWD))
  $env.config = ($env.config | update hooks.env_change.PWD ($env.config.hooks.env_change.PWD | append {|_, dir|
    zoxide add -- $dir
  }))
}

# =============================================================================
#
# When using zoxide with --no-cmd, alias these internal functions as desired.
#

# Jump to a directory using only keywords.
def-env __zoxide_z [...rest:string] {
  let arg0 = ($rest | append '~').0
  let path = if (($rest | str length).0 <= 1) and ($arg0 == '-' or ($arg0 | path expand | path type) == dir) {
    $arg0
  } else {
    (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")'
}

# =============================================================================
#
# Commands for zoxide. Disable these using --no-cmd.
#

alias z = __zoxide_z
alias zi = __zoxide_zi

@asim215
Copy link

asim215 commented Jul 26, 2023

For now I just removed this check in if statement. So it becomes:
let path = if ($arg0 == '-' or ($arg0 | path expand | path type) == dir) {

@KSaiAkshit
Copy link

For now I just removed this check in if statement. So it becomes: let path = if ($arg0 == '-' or ($arg0 | path expand | path type) == dir) {

Thanks for this. It was throwing a weird error when I tried the first fix, adding str before length.

@amtoine
Copy link

amtoine commented Jul 27, 2023

as said in #596, this issue has been fixed in nushell/nushell#9816 and should be released in a patch release soon 😌

JonasLeonhard added a commit to JonasLeonhard/nushell-config that referenced this issue Jul 30, 2023
add a try block around init zoxide in .env
and change the load file temporarily with fix from:
ajeetdsouza/zoxide#595

ajeetdsouza/zoxide#595 (comment)
aswell as change let-env to $env.
sullyj3 added a commit to sullyj3/nix-config that referenced this issue Jul 31, 2023
@asim215
Copy link

asim215 commented Jul 31, 2023

It looks like original if check works fine now with updated nushell 0.83.1.
let path = if (($rest | length) <= 1) and ($arg0 == '-' or ($arg0 | path expand | path type) == dir) {
Thanks!

@ajeetdsouza
Copy link
Owner

Awesome, closing this then. Thanks!

@charlesroper
Copy link

I've updated to nushell 0.83.1 and still seeing the error related to let-env

2023-07-31_08

I thought maybe I could just edit .zoxide.nu but it says "Code generated by zoxide. DO NOT EDIT." at the top. If I manually replace all let-env instances to $env., these changes get replaced by the init script in env.nu.

Solution was to disable to init script from running every time.

I guess if the let-env/$env. change remains in nu, then the init script will need updating.

@Kissaki
Copy link

Kissaki commented Aug 1, 2023

@charlesroper yes, the nushell 0.83.1 release notes explicitly note that let-env won't return

That one is pretty simple to update though with a simple replace/update.

JonasLeonhard added a commit to JonasLeonhard/nushell-config that referenced this issue Aug 2, 2023
- ajeetdsouza/zoxide#595

Reinstalled zoxide with 'cargo install --git https://github.com/ajeetdsouza/zoxide'
instead of ''brew install zoxide' or 'cargo install zoxide' fixed the issue
of 'zoxide init nushell' containing the now deprecated 'let-env',
even though it is fixed in the main branch: https://github.com/ajeetdsouza/zoxide/blob/main/templates/nushell.txt
@JonasLeonhard
Copy link

@charlesroper
I ran into the same issue. My zoxide init nushell contained 'let-env', even though i had the newest zoxide version (v0.9.1) installed via brew install zoxide.
The file for the template should have been fixed in the main branch: https://github.com/ajeetdsouza/zoxide/blob/main/templates/nushell.txt .
To fix zoxide init nushell to contain the updated script, i installed zoxide via cargo install --git https://github.com/ajeetdsouza/zoxide.
Hopefully that helps.

@JonasLeonhard
Copy link

@ajeetdsouza
Is that something that needs to be adressed? It seems like to me that the brew install version contains old code.

@ajeetdsouza
Copy link
Owner

Released in 0.9.2.

@mikecrowe-8451
Copy link

For anybody else coming here, make sure nushell is at 0.83.1 -- .0 still fails

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

No branches or pull requests

9 participants