atuinsh/atuin · critical

No key provided and no existing key file found. Please use '

Error message

No key provided and no existing key file found. Please use 'atuin key' on your other machine, or recover your key from a backup

What it means

When logging in, if the user submits an empty encryption key, atuin falls back to an existing key file. If that key file does not exist and the session is non-interactive, it bails with this message telling the user to recover the key with `atuin key` from the original machine or a backup — without the key, history cannot be decrypted.

Source

Thrown at crates/atuin/src/command/client/account/login.rs:219

        let interactive = self.interactive();
        let mut flag_key = self.key.clone();

        loop {
            let key = match flag_key.take() {
                Some(key) => key,
                None => match read_user_input("encryption key [blank to use existing key file]") {
                    Some(key) => key,
                    // Stdin is exhausted, so re-prompting would spin forever.
                    None => bail!("No encryption key provided"),
                },
            };

            if key.is_empty() {
                if !key_path.exists() {
                    let msg = "No key provided and no existing key file found. Please use 'atuin \
                               key' on your other machine, or recover your key from a backup";
                    if !interactive {
                        bail!(msg);
                    }
                    println!("\n{msg}\n");
                    continue;
                }

                paseto_v4::Key::try_load_from_path(key_path).context(format!(
                    "The key in existing key file at '{}' is invalid",
                    key_path.to_string_lossy()
                ))?;

                return Ok(());
            }

            // The key may be EITHER base64 or a bip39 mnemonic.
            match paseto_v4::Key::try_from_mnemonic(&key) {
                Ok(key) => return store_key(settings, store, &key).await,
                Err(err) if interactive => println!("\n{err}. Please try again.\n"),
                Err(err) => return Err(err.into()),

View on GitHub (pinned to c0c717ab04)

Solutions

  1. Run `atuin key` on the original machine and pass it here: `atuin login --key <key>`
  2. Copy the key file (`~/.local/share/atuin/key`) from the existing machine to the new one, then login with an empty key to reuse it
  3. Restore the key from your backup of the atuin data directory
  4. If truly interactive, re-run in a terminal — the message is only fatal when `interactive` is false

Example fix

// before: non-interactive, no key, no key file
atuin login < /dev/null

// after: fetch key from existing machine, then
OLD: atuin key   # copy output
NEW: atuin login --key "<key-from-old-machine>"
Defensive patterns

Strategy: fallback

Validate before calling

KEY_FILE="$HOME/.local/share/atuin/key"
if [ ! -f "$KEY_FILE" ] && [ -z "$ATUIN_KEY" ]; then
  echo 'Fetch the key with `atuin key` on your original machine first' >&2
  exit 1
fi

Try / catch

if ! atuin login --key "$ATUIN_KEY"; then
  echo "Login failed — recover the key from the original machine or backup" >&2
fi

Prevention

When it happens

Trigger: Running `atuin login` (with or without --key '') on a machine with no `~/.local/share/atuin/key` file, in a non-interactive context so the re-prompt loop is impossible; also fresh containers/second machines.

Common situations: Setting up a new laptop/VM without copying the key file; CI environments without an interactive prompt; lost key file after reinstalling the OS; ATUIN_DATA_DIR pointing somewhere the key was never stored.

Related errors


AI-assisted analysis of atuinsh/atuin@c0c717ab04 (2026-09-12). Data as JSON: /api/errors/dacbd8eaab542212. Report an issue: GitHub.