Skip to content

wt switch fails to resolve base branch for worktree creation: "branch does not exist" #2410

@viicslen

Description

@viicslen

Description

When attempting to create a new worktree using the wt switch -c command inside Nushell, Worktrunk consistently fails with a "branch does not exist" error. This issue appears to be isolated specifically to how Nushell passes arguments/options to wt. It fails regardless of branch naming conventions (slashes, dots, or kebab-case) and affects both local and remote-tracking branches.

Steps to Reproduce

  1. Open Nushell (nu).
  2. Ensure a repository has an existing branch (e.g., releases/4.x.x or dashboard-recommended-actions).
  3. Attempt to create a new worktree based on that branch using the CLI:
    wt switch -c my-new-worktree --base "releases/4.x.x"
    # Alternatively: --base="releases/4.x.x"

Expected Behavior

Worktrunk should gracefully accept the argument from Nushell, resolve the base branch, execute the underlying git worktree add -b command, compute the path via the template, and switch to the newly created directory.

Actual Behavior

The command fails to resolve the base branch, returning:

No branch, tag, or commit named "releases/4.x.x"

(Note: It is highly likely that the literal quotation marks are being passed into the string evaluation, causing the branch lookup to fail).

Technical Context & Isolation Testing

  • Shell Specific (The Core Issue): This failure only happens in Nushell. Testing the exact same command in bash or zsh works perfectly.
  • Argument Parsing Quirk: The issue is directly related to how Nushell handles and passes string arguments/options. However, it seems to be an interaction specific to wt (or its underlying argument parser), as Nushell passes similar arguments to other CLI tools without issue (e.g., git commit --message="message" or git commit --message "message" works flawlessly).
  • Not a character parsing error: Initially suspected to be an issue with periods (.) or forward slashes (/) in the branch name, but the exact same failure occurs with standard alphanumeric/kebab-case branches.
  • Not isolated to upstream: The failure occurs regardless of whether the base branch is remote-only or has already been fetched and checked out locally in the refs/heads/ index.

Environment

  • OS: NixOS Linux
  • Shell: Nushell (issue does not occur in Bash or Zsh)
  • Worktrunk Version: 11caab2
  • Git Version: 2.53.0

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions