{"record":{"id":"3fe3b17043d84734","repo":"atuinsh/atuin","slug":"no-cli-session-found-please-log-in-first-with-atuin-login","errorCode":null,"errorMessage":"No CLI session found. Please log in first with 'atuin login'.","messagePattern":"No CLI session found\\. Please log in first with 'atuin login'\\.","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"crates/atuin/src/command/client/account/link.rs","lineNumber":11,"sourceCode":"use atuin_client::settings::Settings;\nuse eyre::{Result, bail};\n\npub async fn run(settings: &Settings) -> Result<()> {\n    let meta = Settings::meta_store().await?;\n\n    let cli_token = meta.session_token().await?;\n    let hub_token = meta.hub_session_token().await?;\n\n    let Some(cli_token) = cli_token else {\n        bail!(\"No CLI session found. Please log in first with 'atuin login'.\");\n    };\n\n    let hub_address = settings.hub_endpoint();\n\n    if hub_token.is_some() {\n        println!(\"Found both Hub and CLI sessions. Linking accounts...\");\n    } else {\n        println!(\"Found CLI session but no Hub session. Logging in to Hub first...\");\n\n        let session = atuin_client::hub::HubAuthSession::start(&hub_address).await?;\n        println!(\"Open this URL to authenticate with Atuin Hub:\");\n        println!(\"{}\", session.auth_url);\n\n        let token = session\n            .wait_for_completion(\n                atuin_client::hub::DEFAULT_AUTH_TIMEOUT,\n                atuin_client::hub::DEFAULT_POLL_INTERVAL,\n            )","sourceCodeStart":1,"sourceCodeEnd":29,"githubUrl":"https://github.com/atuinsh/atuin/blob/c0c717ab04c881764bcad4b3d169a507e2432643/crates/atuin/src/command/client/account/link.rs#L1-L29","documentation":"The `atuin account link` command links the local CLI account with a Hub session. It requires a CLI session token from the meta store; if none exists (the user never ran `atuin login` on this machine), it bails and instructs the user to log in first.","triggerScenarios":"Running `atuin account link` when `meta.session_token()` returns None — i.e. no prior `atuin login`, a logged-out state, or an ATUIN_CONFIG_DIR pointing to a fresh meta store without a CLI session.","commonSituations":"Setting up Hub linking on a brand-new machine; CI containers without a logged-in CLI; accidentally using a different config directory than the one holding the session; after clearing the meta store.","solutions":["Run `atuin login` to establish a CLI session, then retry `atuin account link`","Verify ATUIN_CONFIG_DIR points at the config that contains your session token","Re-login if the session was cleared or the meta store was recreated","Link via the Hub web UI if CLI login is unavailable"],"exampleFix":"// before (fails: no CLI session)\natuin account link\n\n// after\natuin login\natuin account link","handlingStrategy":"validation","validationCode":"atuin status >/dev/null 2>&1 || { echo 'No CLI session: run `atuin login` before linking'; exit 1; }","typeGuard":null,"tryCatchPattern":"if ! atuin account link; then\n  echo \"Link failed — ensure 'atuin login' was run on this machine\" >&2\nfi","preventionTips":["Complete `atuin login` on every machine before Hub linking","Use one consistent config directory so the session is discoverable","Document the login prerequisite in onboarding/CI setup","Re-login after clearing or recreating the meta store"],"tags":["cli","auth","session"],"backgroundTag":"authentication-required","analyzedSha":"c0c717ab04c881764bcad4b3d169a507e2432643","analyzedAt":"2026-09-12T07:40:01.341Z","contentChangedAt":"2026-09-12T07:40:01.341Z","schemaVersion":2},"datasetVersion":"2026-09-14T05:17:10.506Z"}