{"record":{"id":"3afb0a4caad56401","repo":"gitbutlerapp/gitbutler","slug":"no-git-repository-found-at-please-run-but-setup-to","errorCode":null,"errorMessage":"No git repository found at {}\nPlease run 'but setup' to initialize the project.","messagePattern":"No git repository found at (.+?)\nPlease run 'but setup' to initialize the project\\.","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"crates/but/src/setup.rs","lineNumber":111,"sourceCode":"///   exceeds the configured interval\n///\n/// When a background sync is initiated and the output format allows human UI messages, a\n/// message is written to the output channel showing how long ago the last sync occurred\n/// (e.g., \"Last fetch was 15m ago. Initiated a background fetch...\"). The time is formatted\n/// as seconds (s), minutes (m), hours (h), or days (d) depending on the elapsed duration.\n///\n/// When `background_sync` is `BackgroundSync::Disabled`, no background sync is performed\n/// regardless of the configured interval.\npub fn init_ctx(\n    args: &Args,\n    options: InitCtxOptions,\n    out: &mut OutputChannel,\n) -> anyhow::Result<Context> {\n    let app_settings = crate::app_settings()?;\n    // lets try to get the repo from the current directory\n    let repo = match but_ctx::discover_main_repo(&args.current_dir) {\n        Ok(repo) => repo,\n        Err(_) => anyhow::bail!(\n            \"No git repository found at {}\\nPlease run 'but setup' to initialize the project.\",\n            &args.current_dir.display()\n        ),\n    };\n\n    // Check if we're on gitbutler/workspace with non-workspace commits on top\n    // before creating the context\n    if matches!(options.workspace_check, WorkspaceCheck::Enabled) {\n        check_workspace_commits_before_init(&repo, out)?;\n    }\n\n    let (ctx, fetch_interval_minutes, last_fetch) = {\n        let Some(workdir) = repo.workdir() else {\n            anyhow::bail!(\"Bare repositories are not supported.\");\n        };\n        #[cfg(feature = \"legacy\")]\n        {\n            use but_ctx::LegacyProject;","sourceCodeStart":93,"sourceCodeEnd":129,"githubUrl":"https://github.com/gitbutlerapp/gitbutler/blob/58e5313667b857ef39a730e380af31816a7b1768/crates/but/src/setup.rs#L93-L129","documentation":"During CLI context initialization, `init_ctx` tries to discover the main git repository from the current directory using but_ctx::discover_main_repo. If discovery fails, it aborts with this message telling the user to run `but setup` to initialize the project. In short: you invoked a but command outside any git repository it can find.","triggerScenarios":"Running any but command in a directory that is not inside a git repository (discover_main_repo returns Err for args.current_dir).","commonSituations":"Running `but` in a home directory or non-repo folder; typos in cd; working in a fresh checkout before any git init; forgetting that but requires an existing git repo as its base.","solutions":["cd into your git repository (or its subdirectory) and rerun the command.","If the project is new, run `git init` and then `but setup`.","Run `but setup` in the intended project directory to initialize GitButler metadata."],"exampleFix":"// before (in ~/random-dir)\nbut status\n// after\ncd ~/my-project && but status   # or: git init && but setup","handlingStrategy":"validation","validationCode":"# ensure current dir is inside a git repo before running but\ngit rev-parse --show-toplevel >/dev/null 2>&1 || { echo \"Not a git repo; run but setup\"; exit 1; }","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Check `git rev-parse --show-toplevel` in scripts before invoking but","Always run `but setup` once per new clone","Avoid running but from $HOME or temp dirs"],"tags":["git","cli","setup","repository-not-found"],"backgroundTag":"file-not-found","analyzedSha":"58e5313667b857ef39a730e380af31816a7b1768","analyzedAt":"2026-09-18T06:50:32.052Z","contentChangedAt":"2026-09-18T06:50:32.052Z","schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}