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

Nushell error, cannot find column 'keybindings' #1189

Closed
fabienengels opened this issue Aug 22, 2023 · 8 comments · Fixed by #1270
Closed

Nushell error, cannot find column 'keybindings' #1189

fabienengels opened this issue Aug 22, 2023 · 8 comments · Fixed by #1270

Comments

@fabienengels
Copy link

Hi,

I got an error when using atuin 16.0.0 with nushell 0.83.1 :

Error: nu::shell::column_not_found

  × Cannot find column
    ╭─[/Users/fabien/.config/nushell/atuin-init.nu:39:1]
 39 │     $env.config = ($env.config | default {} hooks)
 40 │ ╭─▶ $env.config = (
 41 │ │       $env.config | upsert hooks (
 42 │ │           $env.config.hooks
 43 │ │           | upsert pre_execution (
 44 │ │               $env.config.hooks | get -i pre_execution | default [] | append $_atuin_pre_execution)
 45 │ │           | upsert pre_prompt (
 46 │ │               $env.config.hooks | get -i pre_prompt | default [] | append $_atuin_pre_prompt)
 47 │ │       )
 48 │ ├─▶ )
    · ╰──── value originates here
 49 │
 50 │     $env.config = (
 51 │         $env.config | upsert keybindings (
 52 │ ╭─▶         $env.config.keybindings
    · │                    ─────┬─────
    · │                         ╰── cannot find column 'keybindings'
 53 │             | append {
    ╰────

I generate atuin source using the following command :

atuin init nu > ~/.config/nushell/atuin-init.nu

And here, my nushell config file :

$env.config = {
    show_banner: false
}

source ~/.config/nushell/atuin-init.nu

Putting the source line first, change anything.

Thank you in advance for your help

@suzdalnitski
Copy link

Is that perhaps an issue with the latest version? I have just installed atuin, and I'm having the exact same issue.

@fabienengels
Copy link
Author

I've just upgraded to the last release of nushell 0.84.0 which comes with a breaking change related to str, so the issue error is still here but now, I got a new one :

Error:   × Deprecated option
    ╭─[/Users/fabien/Library/Application Support/nushell/env.nu:15:1]
 15 │     let dir = ([
 16 │         ($env.PWD | str substring 0..($home | str length) | str replace --string $home "~"),
    ·                                                             ─────┬─────
    ·                                                                  ╰── `str replace --string` is deprecated and will be removed in 0.85.
 17 │         ($env.PWD | str substring ($home | str length)..)
    ╰────
  help: Substring matching is now the default. Use `--regex` or `--multiline` for matching regular expressions.


Error:   × Deprecated option
    ╭─[/Users/fabien/Library/Application Support/nushell/env.nu:23:1]
 23 │
 24 │     $path_segment | str replace --all --string (char path_sep) $"($separator_color)/($path_color)"
    ·                     ─────┬─────
    ·                          ╰── `str replace --string` is deprecated and will be removed in 0.85.
 25 │ }
    ╰────
  help: Substring matching is now the default. Use `--regex` or `--multiline` for matching regular expressions.

From the changelog, the second error seems easy to fix :

If you used str replace with the -s/--string flag, you will get a deprecation warning.
To get rid of the warning, simply remove the flag.

@tmpm697
Copy link

tmpm697 commented Sep 15, 2023

I got the same issue.

@da5is
Copy link

da5is commented Sep 18, 2023

In init.nu, delete the following stanzas for the keybindings

$env.config = (
$env.config | upsert keybindings (
$env.config.keybindings
| append {
name: atuin
modifier: control
keycode: char_r
mode: [emacs, vi_normal, vi_insert]
event: { send: executehostcommand cmd: (_atuin_search_cmd) }
}
)
)
$env.config = (
$env.config | upsert keybindings (
$env.config.keybindings
| append {
name: atuin
modifier: none
keycode: up
mode: [emacs, vi_normal, vi_insert]
event: { send: executehostcommand cmd: (_atuin_search_cmd '--shell-up-key-binding') }
}
)
)

In your config.nu, add the following to the keybindings:

{
name: atuin
modifier: control
keycode: char_r
mode: [emacs, vi_normal, vi_insert]
event: { send: executehostcommand cmd: (_atuin_search_cmd) }
}
{
name: atuin
modifier: none
keycode: up
mode: [emacs, vi_normal, vi_insert]
event: { send: executehostcommand cmd: (_atuin_search_cmd '--shell-up-key-binding') }
}
]
}

The one piece that works but I'm not sure why it's erroring out on current versions of Nu, is that I had to source the init.nu file at the beginning of config.nu and the end of config.nu - otherwise, it didn't work. The downside of that is that the random token generation doesn't work, so I had to statically define a token in init.nu like so:

let ATUIN_KEYBINDING_TOKEN = $"# de075a1d-0cf6-48b2-ad04-fcd90c532d62"

@PhilTaken
Copy link

@fabienengels change your nu config file to

$env.config = {
    show_banner: false
    keybindings: []
}

source ~/.config/nushell/atuin-init.nu

to make it work.

I presume there is no default for keybindings and the atuin nushell integration assumes there to be at least an empty list

@dcarosone
Copy link
Contributor

I presume there is no default for keybindings and the atuin nushell integration assumes there to be at least an empty list

Correct, and maybe a recent change; not sure. The fix is to set one, the same way is done for hooks, in init.nu

$env.config = ($env.config | default [] keybindings)

@dcarosone
Copy link
Contributor

This file is generated; there are two possible patches to fix this. One is to append this line to the template:

diff --git a/atuin/src/shell/atuin.nu b/atuin/src/shell/atuin.nu
index 33ce0068..673e99d0 100644
--- a/atuin/src/shell/atuin.nu
+++ b/atuin/src/shell/atuin.nu
@@ -46,3 +46,5 @@ $env.config = (
             $env.config.hooks | get -i pre_prompt | default [] | append $_atuin_pre_prompt)
     )
 )
+
+$env.config = ($env.config | default [] keybindings)

in which case it will be there every time, even if no keybindings are set.

The other handles this condition:

diff --git a/atuin/src/command/init.rs b/atuin/src/command/init.rs
index 880fcf86..ac41e7e4 100644
--- a/atuin/src/command/init.rs
+++ b/atuin/src/command/init.rs
@@ -98,6 +98,8 @@ bind -M insert \e\[A _atuin_bind_up";
         println!("{full}");

         if std::env::var("ATUIN_NOBIND").is_err() {
+            const BINDS_MAYBE_EMPTY: &str = r#"$env.config = ($env.config | default [] keybindings)
+"#;
             const BIND_CTRL_R: &str = r#"$env.config = (
     $env.config | upsert keybindings (
         $env.config.keybindings
@@ -124,6 +126,7 @@ bind -M insert \e\[A _atuin_bind_up";
     )
 )
 "#;
+            println!("{BINDS_MAYBE_EMPTY}");
             if !self.disable_ctrl_r {
                 println!("{BIND_CTRL_R}");
             }

LMK which you prefer as a PR

@ellie
Copy link
Member

ellie commented Sep 29, 2023

@dcarosone I'd love to accept a PR for your first suggestion please! Nushell has had breaking changes pretty regularly lately (understandable, it's fresh and moving fast). So it's easiest we patch things there

dcarosone pushed a commit to dcarosone/atuin that referenced this issue Sep 29, 2023
ellie pushed a commit that referenced this issue Sep 29, 2023
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