Skip to content

History database gets corrupted on clearing #14244

Closed

Description

@yerlaser

Describe the bug

I tried to clear history with history -c and this command succeeded, but when launching a new instance I get this error:

Error:   × error within history database: SqliteFailure(Error { code: SystemIoFailure, extended_code: 522 }, Some("disk I/O error"))
[process exited with code 1 (0x00000001)]

I had to manually delete all the sqlite files to make nu start again.

How to reproduce

  1. Better do it on a separate instance with a separate history or backup your history files
  2. Also make sure you have another terminal open with a different shell so that you can delete the sqlite3 files
  3. Run: history -c
  4. Try to launch another instance of the terminal

Expected behavior

Open with empty history

Configuration

Compiled from latest sources and displayed as: 0.99.2 on Ubuntu WSL

Activity

  1. added
    status:needs-triage
    on Nov 3, 2024
  2. added
    A:line-editor
    A:history
    on Nov 5, 2024
  3. yerlaser commented on Nov 18, 2024

    @yerlaser
    Author

    Upgraded to version 100 and the issue persists.

  4. NotTheDr01ds commented on Aug 25, 2025

    @NotTheDr01ds
    Contributor

    I can still reproduce this under 106.1, but once I exit out of the session in which I did history -c, I can start new sessions just fine.

  5. added
    category:bug
    and removed
    status:needs-triage
    on Aug 25, 2025
  6. yerlaser commented on Aug 25, 2025

    @yerlaser
    Author

    I can still reproduce this under 106.1, but once I exit out of the session in which I did history -c, I can start new sessions just fine.

    Ah, OK. Now I understand.
    This means the DB isn't corrupted, but simply the session keeps a lock on the file.
    Probably in that case we need to document this in the output of history -c command.

    I can create the PR for the doc if you agree.

  7. NotTheDr01ds commented on Aug 25, 2025

    @NotTheDr01ds
    Contributor

    I still consider it a bug that it doesn't release the lock after history -c, so I'd rather just keep this open than "document the bug".

  8. CharlesTaylor7 commented on Dec 14, 2025

    @CharlesTaylor7
    Contributor

    I got this crash when using the up arrow in the terminal.
    I was going to open an issue, but this appears to be the same/similar?

    …/dotfiles
    ❯ history -c
    
    …/dotfiles
    ❯ history
    ╭────────────╮
    │ empty list │
    ╰────────────╯
    
    …/dotfiles
    ❯ Error:   × Main thread panicked.
      ├─▶ at /Users/runner/.cargo/registry/src/index.crates.io-1949cf8c6b5b557f/reedline-0.44.0/src/history/sqlite_backed.rs:128:14
      ╰─▶ called `Result::unwrap()` on an `Err` value: SqliteFailure(Error { code: Unknown, extended_code: 1 }, Some("no such table: history"))
      help: set the `RUST_BACKTRACE=1` environment variable to display a backtrace.
    
  9. added this to the 1.0 milestone on Oct 9, 2026
  10. added a commit that references this issue on Oct 9, 2026
    76126ff
  11. modified the milestones: 1.0, v0.117.0 on Oct 31, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    A:historyA:line-editorcategory:bug

    Type

    No type

    Projects

    No projects

      Milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions