gitbutlerapp/gitbutler · error

worktree manipulation is not enabled…

Error message

worktree manipulation is not enabled (featureFlags.worktreeManipulation)

What it means

`ensure_worktree_manipulation_enabled` guards all worktree-mutating/listing APIs behind the experimental `featureFlags.worktreeManipulation` setting. If the flag is off in `ctx.settings`, any guarded call (open changes source, list worktrees, archive/remove a worktree) fails immediately.

Solutions

  1. Enable the flag in settings: set `featureFlags.worktreeManipulation` to `true` in the GitButler config and retry
  2. Upgrade GitButler to a version where the feature is enabled by default if available
  3. Avoid the guarded APIs and use plain `git worktree` commands if you cannot change settings

Example fix

// before
await api.worktreesList(ctx); // fails: flag off
// after
ctx.settings.featureFlags.worktreeManipulation = true; // or set in config
await api.worktreesList(ctx);
Defensive patterns

Strategy: try-catch

Validate before calling

if (!ctx.settings.featureFlags.worktreeManipulation) {
  throw new Error('enable featureFlags.worktreeManipulation to use worktree APIs');
}

Type guard

const worktreesEnabled = (ctx: Context): boolean =>
  ctx.settings?.featureFlags?.worktreeManipulation === true;

Try / catch

try {
  await api.worktreesList(ctx);
} catch (e) {
  if (e.message.includes('worktree manipulation is not enabled')) showOptInDialog();
}

Prevention

When it happens

Trigger: Calling `worktrees_list`, `worktree_set_archived(_with_perm)`, `worktree_remove`, or `open_changes_source` while `ctx.settings.feature_flags.worktree_manipulation` is `false`.

Common situations: A user on a default/older configuration invokes new worktree features; an SDK consumer never set the opt-in flag; a script automates worktrees on an installation that has not enabled the experiment.

Related errors


AI-assisted analysis of gitbutlerapp/gitbutler@58e5313667 (2026-09-18). Data as JSON: /api/errors/10fecf8effeca92d. Report an issue: GitHub.

Appendix: source

Thrown at crates/but-api/src/worktrees.rs:75

/// updated first and otherwise by name.
#[derive(Debug, Clone, Serialize)]
#[cfg_attr(feature = "export-schema", derive(schemars::JsonSchema))]
#[serde(rename_all = "camelCase")]
pub struct WorktreeListing {
    /// Non-archived worktrees.
    pub active: Vec<ListedWorktree>,
    /// Archived worktrees, hidden from the workspace but still on disk.
    pub archived: Vec<ListedWorktree>,
}
#[cfg(feature = "export-schema")]
but_schemars::register_sdk_type!(ListedWorktree);
#[cfg(feature = "export-schema")]
but_schemars::register_sdk_type!(WorktreeListing);

/// Fail unless the user opted into worktree manipulation.
pub fn ensure_worktree_manipulation_enabled(ctx: &but_ctx::Context) -> Result<()> {
    if !ctx.settings.feature_flags.worktree_manipulation {
        bail!("worktree manipulation is not enabled (featureFlags.worktreeManipulation)");
    }
    Ok(())
}

/// Look up the *active* linked worktree named `name`.
///
/// Every command here operates on active worktrees only - an archived one is
/// hidden from the graph, so operations against it could not be materialized.
///
/// Must not be called while a database handle is borrowed, see
/// [`but_ctx::Context::worktrees_with_state()`].
fn active_worktree(ctx: &but_ctx::Context, name: &str) -> Result<WorktreeEntry> {
    let worktree = ctx
        .worktrees_with_state()?
        .into_iter()
        .find(|worktree| worktree.name == name.as_bytes())
        .with_context(|| format!("Worktree {name} does not exist"))?;
    if worktree.archived {

View on GitHub (pinned to 58e5313667)