Up-arrow error & commands not saved

When I press the up arrow, I get:

-bash: bash_execute_unix_command: cannot find keymap for command

C-r and C-x C-p show Atuin as expected, though no history is saved since I installed.

I’m on GNU bash, version 4.2.46(2)-release (x86_64-redhat-linux-gnu) (not my call) with bash-preexec 0.5.0 and atuin 18.2.0 , both from homebrew. I use vi keybindings.

The relevant bit of .bashrc amounts to:

. "${HOMEBREW_PREFIX}/etc/profile.d/bash-preexec.sh"
#export ATUIN_NOBIND="true"  # workaround
command -v atuin &>/dev/null && eval "$(atuin init bash)"

The same setup works as expected on WSL Ubuntu.

I tried to look through atuin init bash and help bind but I’m out of my depth. Any pointers would be much appreciated!

Is it possible for you to also install bash from homebrew? 4.2 came out 13 years ago now :confused:

There’s an open issue for this one here: bash_execute_unix_command: cannot find keymap for command · Issue #962 · atuinsh/atuin · GitHub

If you could also share the output of atuin doctor would be great please!

1 Like

Ah, I added a workaround for Bash <= 4.2 in #1515, but I now noticed that it is broken for the vi-editing modes of Bash. I’ll submit a fix.

2 Likes

4.2 came out 13 years ago now :confused:

Tell that to my sysadmins! Or the CentOS 7 maintainers.


I installed homebrew’s bash (5.2.26(1)-release) and finagled it into being my login shell. The keybinds worked as expected there. (@akinomyoga I’d still be interested in your fix.)

But it’s still not saving new commands. Does that mean I need to look at bash-preexec?


This looks the same on both bash versions:

Atuin Doctor
Checking for diagnostics

[Shell] If you are using Bash, Atuin requires that either bash-preexec or ble.sh be installed. An older ble.sh may not be detected. so ignore this if you have it set up! Read more here: https://docs.atuin.sh/guide/installation/#bash

Please include the output below with any bug reports or issues

atuin:
  version: 18.2.0
  sync:
    cloud: true
    records: false
    auto_sync: true
    last_sync: 2024-03-08 5:25:03.70084772 +00:00:00
shell:
  name: bash
  default: unknown
  plugins:
  - atuin
system:
  os: CentOS Linux
  arch: x86_64
  version: '7'
  disks:
  - name: /dev/mapper/sysvg-root
    filesystem: xfs
  - name: /dev/vda1
    filesystem: xfs
  - name: /dev/mapper/sysvg-data
    filesystem: xfs

CentOS 7 is also 10 years old, and they will not change core packages for stability and compatibility once it is released.

Even if the system Bash is old, you do not have to use the system Bash. You can build a new version of Bash, install it in your home directory, and use it for your interactive sessions. OK, you’ve installed a new version through Homebrew.

The patch was already merged.

The result of atuin doctor suggests that you load neither bash-preexec nor ble.sh. You need to enable bash-preexec by sourcing the file somewhere in your Bash startup files. If the system configuration does not load bash-preexec, you need to source bash-preexec in ~/.bashrc.

This is getting weird. I have had bash-preexec installed and sourced the whole time. I don’t think anything’s changed, but now …

atuin doctor looks better
Atuin Doctor
Checking for diagnostics


Please include the output below with any bug reports or issues

atuin:
  version: 18.2.0
  sync:
    cloud: true
    records: false
    auto_sync: true
    last_sync: 2024-03-08 5:25:03.70084772 +00:00:00
shell:
  name: bash
  default: unknown
  plugins:
  - atuin
  - bash-preexec
system:
  os: CentOS Linux
  arch: x86_64
  version: '7'
  disks:
  - name: /dev/mapper/sysvg-root
    filesystem: xfs
  - name: /dev/vda1
    filesystem: xfs
  - name: /dev/mapper/sysvg-data
    filesystem: xfs

For the record, here’s evidence of bash-preexec:

$ brew list --versions | head -3
atuin 18.2.0
bash 5.2.26
bash-preexec 0.5.0
$ [ -r "${HOMEBREW_PREFIX}/etc/profile.d/bash-preexec.sh" ] && echo 'BP is installed'
BP is installed
$ echo "$bash_preexec_imported"
defined

And I source it almost last in .bashrc, as recommended. I abbreviated this above, but here is the very end of the file:

end of .bashrc, with bash-preexec & atuin
# ble.sh & Atuin
# https://docs.atuin.sh/guide/installation/
if [[ ${BLE_VERSION-} ]]; then
    ble-attach
else
    # defined above: sc_if_r () { [ -r "$1" ] && \. "$1"; }
    sc_if_r "${HOMEBREW_PREFIX}/etc/profile.d/bash-preexec.sh" || sc_if_r "${HOME}/.bash-preexec.sh"
fi
command -v atuin &>/dev/null && eval "$(atuin init bash)"

#####  Clean up  #####
path_dedup 2>/dev/null
unset sc_if_r this_is_port can_brew found_brew brew_bash ls_args thisdir omp_config

Well above that, I also source oh-my-posh, which I suspected of interfering with preexec, but disabling OMP doesn’t fix atuin.

I don’t have an idea currently. Just in case, what are the permissions of the related files? What are the results of the following commands?

$ /usr/bin/ls -la ~/.local
$ /usr/bin/ls -la ~/.local/share/atuin

If you set XDG_DATA_HOME to another path, please adjust the paths in the above command accordingly.

$ /usr/bin/ls -la ~/.local
total 8
drwxr-xr-x  7 jacktose users   69 Nov  9  2023 .
drwx--x--- 37 jacktose users 4096 Jun  5 12:35 ..
drwxr-xr-x  3 jacktose users 4096 Dec 18 14:37 bin
drwxr-xr-x  3 jacktose users   18 Sep  8  2023 include
drwxr-xr-x  5 jacktose users   52 Nov  9  2023 lib
drwxr-xr-x 11 jacktose users  128 Mar  7 21:23 share
drwxr-xr-x  3 jacktose users   16 Sep  8  2023 state
$ /usr/bin/ls -la ~/.local/share/atuin
total 15312
drwx------  2 jacktose users     4096 Mar 22 09:49 .
drwxr-xr-x 11 jacktose users      128 Mar  7 21:23 ..
-rw-------  1 jacktose users 10801152 Mar 28 15:00 history.db
-rw-------  1 jacktose users    32768 Jun  5 11:50 history.db-shm
-rw-------  1 jacktose users  4647392 Mar  7 21:24 history.db-wal
-rw-------  1 jacktose users       32 Mar  7 21:26 host_id
-rw-------  1 jacktose users       64 Mar  7 21:24 key
-rw-------  1 jacktose users       29 Mar  7 21:25 last_sync_time
-rw-------  1 jacktose users       30 Jun  5 11:16 last_version_check_time
-rw-------  1 jacktose users        6 Jun  5 11:16 latest_version
-rw-------  1 jacktose users    49152 Apr 18 10:36 records.db
-rw-------  1 jacktose users    32768 Jun  5 11:50 records.db-shm
-rw-------  1 jacktose users    82432 Mar  7 21:23 records.db-wal
-rw-------  1 jacktose users       32 Mar  7 21:24 session

The keybind problem was worked around by using newer bash (from homebrew). But now (Atuin 18.3.0) it works on bash 4.2 also. Thanks @akinomyoga!


And I solved the not-saving issue! I’d broken bash-preexec. It was not Atuin’s fault, and it was dumb.

I source bash-preexec.sh near the end of my .bashrc, but I was also sourcing it much earlier, along with all profile.d scripts:

for PROFILE in "${HOMEBREW_PREFIX}/etc/profile.d/"*; do
    [ -r "${PROFILE}" ] && \. "${PROFILE}"
done

And it prevents re-sourcing:

# Avoid duplicate inclusion
if [[ -n "${bash_preexec_imported:-}" ]]; then
    return 0
fi
bash_preexec_imported="defined"

So my inelegant solution is to trick it into sourcing again:

unset bash_preexec_imported  # Force it to re-source.
[ -r "${HOMEBREW_PREFIX}/etc/profile.d/bash-preexec.sh" ] && \. "${HOMEBREW_PREFIX}/etc/profile.d/bash-preexec.sh"
command -v atuin &>/dev/null && eval "$(atuin init bash)"

And now Atuin is working as expected. Huzzah!

1 Like

I too had the problem of new commands not being saved. It was driving me crazy!:slight_smile:

In the end I realized it was because of including GitHub - micharbet/CLE: Command Live Environment in my .bashrc. I did that a few years ago and completely forgot about it. Realizing that I wasn’t really using any of its features, I just removed it. Now atuin seems to record the history as it should.

1 Like