{"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":"exception","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/900007c48045867e7f44b0f9bc55ad9dbe99ee0d/crates/atuin/src/command/client/account/link.rs#L1-L29","documentation":"`atuin account link` needs the local CLI session token to link the CLI account with a Hub account, but the meta store returned no CLI session. The command bails and tells the user to log in first, since linking is meaningless without an authenticated CLI session.","triggerScenarios":"Running `atuin account link` before `atuin login`; running it on a machine where only Hub browser sessions exist but the CLI was never logged in; session token cleared by logout or a fresh data directory.","commonSituations":"Setting up a new workstation and running link before login; CI environments with no session; mixing ATUIN_HOME directories so the token lives elsewhere.","solutions":["Run `atuin login` (or `atuin register`) first, then retry `atuin account link`","Point ATUIN_HOME at the directory that holds your existing CLI session","Verify session state exists before linking (e.g. a successful sync run implies a session)"],"exampleFix":"// before\natuin account link\n// after\natuin login\natuin account link","handlingStrategy":"validation","validationCode":"atuin login || { echo 'CLI login required before link'; exit 1; }","typeGuard":null,"tryCatchPattern":"atuin account link || { echo 'Run atuin login first'; exit 1; }","preventionTips":["Run `atuin login` as part of new-machine setup before hub linking","Use the same ATUIN_HOME across setup steps","Treat link as a post-login step in provisioning scripts"],"tags":["cli","authentication","session","hub"],"backgroundTag":"authentication-required","analyzedSha":"900007c48045867e7f44b0f9bc55ad9dbe99ee0d","analyzedAt":"2026-09-19T12:52:51.491Z","contentChangedAt":"2026-09-19T12:52:51.491Z","schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}