gitbutlerapp/gitbutler · error
GitHub stacks configuration requires a repository
Error message
GitHub stacks configuration requires a repository
What it means
The `but config forge` dispatcher only handles Auth, ListUsers, Forget, and overview subcommands without a repository. The legacy `github-stacks` subcommand is repository-scoped; when forge_config is reached without a project context (the `exec` caller passes None), it is intentionally rejected as unsupported rather than misbehaving.
Solutions
- Run the command from inside a git repository so a project context is available
- Use a non-repository forge subcommand such as `but config forge auth` or `but config forge list-users` instead
- Update the CLI: the legacy github-stacks subcommand is feature-gated and may be removed in favor of newer forge commands
Example fix
// before but config forge github-stacks # run from ~/ // after cd /path/to/repo && but config forge github-stacks
Defensive patterns
Strategy: validation
Validate before calling
if (args.some(a => a === 'github-stacks')) {
assert(isInsideGitRepo(process.cwd()), 'github-stacks requires a repository context');
} Type guard
const isRepoScopedForgeCmd = (sub) => ['github-stacks'].includes(sub);
Try / catch
try {
await exec('but config forge github-stacks ...');
} catch (e) {
if (e.message.includes('requires a repository')) {
console.error('cd into a git repository first');
process.exitCode = 1;
} else throw e;
} Prevention
- Check the subcommand's repo requirements before scripting legacy forge commands
- Prefer `forge auth`/`list-users` for non-repo contexts
- Avoid relying on feature-gated legacy subcommands in automation
When it happens
Trigger: Invoking `but config forge github-stacks ...` (legacy feature) in a context where no repository is open — e.g. outside a git repo or via a code path that passes no project handle — hits the bail in the ForgeSubcommand::GithubStacks match arm.
Common situations: Users on legacy builds running `but config forge github-stacks` outside a repository; scripts calling forge configuration before opening a project; environments where the legacy feature is compiled in but no repo context exists.
Understand the failure class
Background: "X is required", "must be set", "cannot be empty": the missing-required-config error family, from Vertex AI project/location to WeChat keys — this error's family across 18 libraries.
Related errors
- Aborting due to empty branch name
- Bare repositories are not supported.
- Branch ' ' not found
- Branch ' ' not found when checking for conflicts
- Branch " " has no conflicted commits.
AI-assisted analysis of gitbutlerapp/gitbutler@58e5313667 (2026-09-18).
Data as JSON: /api/errors/fced72c22b1884fd.
Report an issue: GitHub.
Appendix: source
Thrown at crates/but/src/command/config.rs:622
}
}
}
Ok(())
}
/// Handle forge config subcommand (doesn't require repo context)
pub(crate) async fn forge_config(
out: &mut OutputChannel,
cmd: Option<ForgeSubcommand>,
) -> Result<()> {
match cmd {
Some(ForgeSubcommand::Auth) => forge_auth(out).await,
Some(ForgeSubcommand::ListUsers) => forge_show_overview(out).await,
Some(ForgeSubcommand::Forget { username }) => forge_forget(username, out).await,
#[cfg(feature = "legacy")]
Some(ForgeSubcommand::GithubStacks { .. }) => {
anyhow::bail!("GitHub stacks configuration requires a repository")
}
None => forge_show_overview(out).await,
}
}
#[cfg(feature = "legacy")]
pub(crate) fn github_stacks_config(
ctx: &mut Context,
out: &mut OutputChannel,
status: Option<GitHubStacksStatus>,
) -> Result<()> {
let configured = {
let repo = ctx.repo.get()?;
match status {
Some(status) => {
let mode = match status {
GitHubStacksStatus::Auto => GitHubStackingMode::Auto,
GitHubStacksStatus::Enable => GitHubStackingMode::Native,View on GitHub (pinned to 58e5313667)