{"record":{"id":"c826c7e8675703f3","repo":"gitbutlerapp/gitbutler","slug":"cannot-use-relative-path-outside-a-git-repositor","errorCode":null,"errorMessage":"Cannot use relative --path outside a git repository unless --global is specified.\nUse --global --path <path> for a global installation, use an absolute path, or run from within a repository for local installation.","messagePattern":"Cannot use relative --path outside a git repository unless --global is specified\\.\nUse --global --path <path> for a global installation, use an absolute path, or run from within a repository for local installation\\.","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"crates/but/src/command/skill/mod.rs","lineNumber":1277,"sourceCode":"    // Validate flags\n    if detect && custom_path.is_some() {\n        anyhow::bail!(\"Cannot use both --detect and --path options together\");\n    }\n    // Only a local scope needs the repository: global installs resolve against\n    // the home directory and absolute or tilde paths need no base at all.\n    let custom_is_absolute = custom_path.as_deref().is_some_and(|custom| {\n        expand_tilde(custom)\n            .unwrap_or_else(|| PathBuf::from(custom))\n            .is_absolute()\n    });\n    let mut ctx = if global || custom_is_absolute {\n        None\n    } else {\n        repository_context(current_dir)?\n    };\n    let ctx = ctx.as_mut();\n    if ctx.is_none() && !global && custom_path.is_some() && !custom_is_absolute {\n        anyhow::bail!(\n            \"Cannot use relative --path outside a git repository unless --global is specified.\\n\\\n             Use --global --path <path> for a global installation, use an absolute path, or run from within a repository for local installation.\"\n        );\n    }\n\n    // Determine installation path(s). Only --detect can yield more than one, when\n    // several GitButler skills share a scope; they are all refreshed together.\n    let agent_default_path = if custom_path.is_none() && !detect {\n        driving_agent.and_then(agent_default_install_path)\n    } else {\n        None\n    };\n    let installed_for_driving_agent = agent_default_path.is_some();\n    let install_paths = if let Some(custom) = custom_path {\n        vec![resolve_custom_path(&custom, ctx, global)?]\n    } else if detect {\n        detect_install_paths(ctx, global)?\n    } else if let Some(path) = agent_default_path {","sourceCodeStart":1259,"sourceCodeEnd":1295,"githubUrl":"https://github.com/gitbutlerapp/gitbutler/blob/58e5313667b857ef39a730e380af31816a7b1768/crates/but/src/command/skill/mod.rs#L1259-L1295","documentation":"A relative `--path` needs a base directory: either the current git repository (for a local install) or, with `--global`, the home directory. When there is no repository context (`ctx.is_none()`, e.g. run outside any git repo), `--global` was not passed, and the path is relative, install_skill cannot resolve it and bails.","triggerScenarios":"Running `but skill install --path ./skills` (relative path, no `--global`) outside of a git repository.","commonSituations":"Running the CLI in a non-git directory (home, /tmp) with a relative path; forgetting `--global` when intending a user-wide install.","solutions":["Use `--global --path <path>` for a global (home-based) installation.","Pass an absolute path so no base directory is needed.","Run the command from inside a git repository for a local installation."],"exampleFix":"// before (outside a repo)\nbut skill install --path ./skills\n// error: Cannot use relative --path outside a git repository...\n\n// after\nbut skill install --global --path ~/.claude/skills/gitbutler","handlingStrategy":"validation","validationCode":"# shell: resolve to absolute path or require a repo\nif [[ \"$SKILL_PATH\" != /* ]]; then\n  git rev-parse --is-inside-work-tree >/dev/null 2>&1 || SKILL_ARGS=\"--global $SKILL_ARGS\"\nfi","typeGuard":null,"tryCatchPattern":"but skill install --path \"$SKILL_PATH\" 2>err.log || { grep -q 'relative --path outside a git repository' err.log && but skill install --global --path \"$SKILL_PATH\"; }","preventionTips":["Always pass absolute paths to --path.","Use --global when installing outside a repository.","Check `git rev-parse --is-inside-work-tree` before local installs."],"tags":["cli","path-resolution","git-repository"],"backgroundTag":"invalid-argument-value","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"}