Error in nushell + tmux - hoping someone can help #1131
|
When I fire up a new window or pane in tmux, I get the following error: Error: nu::shell::cant_convert
× Can't convert to boolean.
╭─[Host Environment Variables:83:19]
82 │ "__CF_USER_TEXT_ENCODING"="0x1F5:0x0:0x0"
83 │ "__zoxide_hooked"="true"
· ───┬──
· ╰── can't convert string to boolean
84 │ "is_vim"="echo \"#{pane_current_command}\" | grep -iqE \"(^|\\/)g?(view|n?vim?)(diff)?$\""
╰────The auto-generated `~/.zoxide.nu includes the following snippet where we can see that we are indeed setting __zoxide_hooked to a boolean value (not a string). # =============================================================================
#
# Hook configuration for zoxide.
#
# 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
}))
}Has anyone navigated this issue when using tmux with nushell? It's an error that fires-up when I start the a new window or pane, but does not actually prevent |
Replies: 2 comments
|
The following patch partially fixes the problem. It removes any errors when I create a new tmux pane or window. That good. But my ability to restore a session is hit and miss. Some of the pains are not institutionalizing correctly. In general, tmux seems to pass $env value as strings. The script needs to support deserializing accordingly. ---------------------------------------------------------Zoxide patchdef regen-zoxide-nu [] { let stock = (zoxide init nushell) let patched = ( $patched | save -f ~/.zoxide.nu Run the patchregen-zoxide-nu Zoxide initializationsource ~/.zoxide.nu End patch--------------------------------------------------------- |
|
Update zoxide to v0.10.0 and regenerate your init file: zoxide init nushell | save -f ~/.zoxide.nuThe old init script stored You'll need nushell v0.106.0+ for the new init script. |
Update zoxide to v0.10.0 and regenerate your init file:
The old init script stored
__zoxide_hookedas$env.__zoxide_hooked = true. Tmux serializes all env vars as strings when it spawns a pane, so nushell sees"true"instead oftrueand throwscant_convert. The v0.10.0 template doesn't use that env var anymore. It checks the hooks config with a local variable instead, so tmux can't break it.You'll need nushell v0.106.0+ for the new init script.