{"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":"anyhow::Error","httpStatus":null,"severity":"error","filePath":"crates/but/src/command/skill/mod.rs","lineNumber":416,"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/// Replace version in SKILL.md content\nfn inject_version(content: &str, version: &str) -> String {\n    // Handle different line endings (Unix \\n, Windows \\r\\n, or old Mac \\r)\n    let frontmatter_end = content\n        .find(\"---\\n\\n\")\n        .or_else(|| content.find(\"---\\r\\n\\r\\n\"))\n        .or_else(|| content.find(\"---\\r\\r\"));\n","sourceCodeStart":398,"sourceCodeEnd":434,"githubUrl":"https://github.com/gitbutlerapp/gitbutler/blob/caf1f223d3cfb94488c9198ad34487c6006c648f/crates/but/src/command/skill/mod.rs#L398-L434","documentation":"`but skill install` without --global installs into the current git repository's root, which it obtains from a discovered Context. When no repository is found in or above the cwd, ctx is None and the command explains the two valid modes: run inside a repo, or pass --global.","triggerScenarios":"Running `but skill install <skill>` in a plain directory with no .git in it or any parent (home dir, /tmp, a fresh folder) without --global.","commonSituations":"Installing a skill from the home directory; CI steps that run before the repo checkout step; forgetting the --global flag.","solutions":["cd into the target git repository and rerun the command","Or pass --global to install into the home directory instead","In scripts, gate the call on `git rev-parse --git-dir` succeeding"],"exampleFix":"# before\n~ $ but skill install my-skill          # not a repo -> error\n# after\n~ $ but skill install my-skill --global\n# or\ncd ~/src/myrepo && but skill install my-skill","handlingStrategy":"validation","validationCode":"match gix::discover(std::env::current_dir()?) {\n    Ok(_) => { /* repo-local install is safe */ }\n    Err(_) if !global => anyhow::bail!(\"run inside a git repository or pass --global\"),\n    Err(_) => {}\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Verify `git rev-parse --git-dir` succeeds before headless installs","Default to --global when the script's cwd is not guaranteed to be a repo"],"tags":["skill","install","git-repository","cli-usage"],"backgroundTag":"not-a-git-repository","analyzedSha":"caf1f223d3cfb94488c9198ad34487c6006c648f","analyzedAt":"2026-08-20T07:55:40.983Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-14T05:17:10.506Z"}