{"record":{"id":"e086adc59077bbca","repo":"gitbutlerapp/gitbutler","slug":"not-in-a-git-repository-use-global-to-install-g","errorCode":null,"errorMessage":"Not in a git repository. Use --global to install globally, or run from within a repository.","messagePattern":"Not in a git repository\\. Use --global to install globally, or run from within a repository\\.","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"crates/but/src/command/skill/mod.rs","lineNumber":528,"sourceCode":"        home_dir().map(|home| {\n            if path_str == \"~\" {\n                home\n            } else {\n                home.join(&path_str[2..])\n            }\n        })\n    } else {\n        None\n    }\n}\n\n/// Get the base directory for installation (repo root or home directory)\nfn get_base_dir(ctx: Option<&mut Context>, global: bool) -> Result<PathBuf> {\n    if global {\n        home_dir().ok_or_else(|| anyhow::anyhow!(\"Could not determine home directory\"))\n    } else {\n        let ctx = ctx.ok_or_else(|| {\n            anyhow::anyhow!(\n                \"Not in a git repository. Use --global to install globally, or run from within a repository.\"\n            )\n        })?;\n        let repo = ctx.repo.get()?;\n        repo.workdir()\n            .ok_or_else(|| anyhow::anyhow!(\"Not in a Git repository\"))\n            .map(|p| p.to_path_buf())\n    }\n}\n\n/// Byte range of the frontmatter's closing `---` line plus the blank line\n/// after it, for any line ending (Unix, Windows, or old Mac). `None` unless\n/// the content opens with a frontmatter block, so a Markdown `---` rule in a\n/// document without one is never mistaken for the delimiter.\nfn frontmatter_close(content: &str) -> Option<std::ops::Range<usize>> {\n    if !(content.starts_with(\"---\\n\") || content.starts_with(\"---\\r\")) {\n        return None;\n    }","sourceCodeStart":510,"sourceCodeEnd":546,"githubUrl":"https://github.com/gitbutlerapp/gitbutler/blob/58e5313667b857ef39a730e380af31816a7b1768/crates/but/src/command/skill/mod.rs#L510-L546","documentation":"When installing a skill locally (no `--global`), the base directory is derived from the current repository via the CLI `Context`. This error is thrown when that context is `None`, meaning the command was not run inside a Git repository that GitButler could recognize.","triggerScenarios":"Running `but skill install <skill>` (without `--global`) outside any Git repository, or in a directory where the Context failed to initialize (no `.git` found), so `get_base_dir` receives `ctx: None`.","commonSituations":"Running the command in `$HOME`, `/tmp`, or a plain folder that is not a git repo; typo'd working directory in scripts; intending a global install but forgetting the `--global` flag.","solutions":["`cd` into your Git repository before running `but skill install`.","If you actually want a user-level install, add the `--global` flag.","Verify the directory is a repo: `git rev-parse --show-toplevel` should print a path."],"exampleFix":"// before\ncd /tmp && but skill install ./my-skill\n\n// after\ncd /path/to/repo && but skill install ./my-skill   # or: but skill install --global ./my-skill","handlingStrategy":"validation","validationCode":"// shell, before running the command\ngit rev-parse --show-toplevel >/dev/null 2>&1 || { echo \"not in a git repo; cd into one or use --global\"; exit 1; }","typeGuard":null,"tryCatchPattern":"match install(opts) {\n    Err(e) if e.to_string().contains(\"Not in a git repository\") =>\n        eprintln!(\"cd into a repo or pass --global\"),\n    other => other?,\n}","preventionTips":["Run `git rev-parse --show-toplevel` first in scripts to confirm repo context.","Add `--global` when installing from non-repo directories.","Avoid running the CLI from $HOME or /tmp in automation."],"tags":["git","cli","repository-context"],"backgroundTag":"resource-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"}