atuinsh / atuin

✨ Magical shell history
https://atuin.sh
MIT License
20.15k stars 545 forks source link

[Bug]: some commands are missed by atuin for no apparent reason? #2361

Open aborrero opened 1 month ago

aborrero commented 1 month ago

What did you expect to happen?

When I type on one terminal window this:

arturo@nostromo:~$ stty raw -echo

I open another terminal window, run atuin (CTRL+R) and I see the above command as the last command.

What happened?

I typed on one terminal window this:

arturo@nostromo:~$ stty raw -echo

Then opened another terminal window, hit CTRL+R to open the atuin panel, and the above command was not present.

Atuin doctor output

{
  "atuin": {
    "version": "18.3.0",
    "sync": {
      "cloud": true,
      "records": false,
      "auto_sync": true,
      "last_sync": "2024-08-12 16:46:07.182128342 +00:00:00"
    },
    "sqlite_version": "3.44.0"
  },
  "shell": {
    "name": "bash",
    "default": "bash",
    "plugins": [
      "atuin",
      "bash-preexec"
    ],
    "preexec": "bash-preexec"
  },
  "system": {
    "os": "Debian GNU/Linux",
    "arch": "x86_64",
    "version": "unknown",
    "disks": [
      {
        "name": "/dev/mapper/nostromo--vg-root",
        "filesystem": "ext4"
      },
      {
        "name": "/dev/nvme0n1p2",
        "filesystem": "ext2"
      },
      {
        "name": "/dev/mapper/nostromo--vg-tmp",
        "filesystem": "ext4"
      },
      {
        "name": "/dev/mapper/nostromo--vg-var",
        "filesystem": "ext4"
      },
      {
        "name": "/dev/mapper/nostromo--vg-home",
        "filesystem": "ext4"
      },
      {
        "name": "/dev/nvme0n1p1",
        "filesystem": "vfat"
      }
    ]
  }
}


### Code of Conduct

- [X] I agree to follow this project's Code of Conduct
ellie commented 1 month ago

Hey! Thanks for the issue

Firstly some context - bash does not provide shell hooks, which we require to hook into the lifecycle of a command. To work around this, we use bash-preexec. It mostly solves the problem, but isn't quite as effective as a native integration. All other shells we support have hooks included as standard.

While the cause of your specific problem is unclear, it will likely be solved by using ble.sh instead of bash-preexec. We can't do this by default as it's a much larger change to your shell

Otherwise, could you share the version of Bash you're using please? Older versions have more edge cases here

aborrero commented 1 month ago

Ok, I will try with ble.sh and report back.

I wish there was an atuin log one could access to see what internal code path atuin was experiencing for processing a given shell command. Can you advice about this?

ellie commented 1 month ago

you could

export ATUIN_LOG=debug

It'll be really chatty

Though if it's an issue with the shell integration, Atuin may not be being invoked at all. So logs won't really help you there