Skip to content

Create worktree fails when you need git lfs #212

Description

@frenchie4111

Title: create_worktree fails when repo uses Git LFS and git-lfs is installed via Homebrew

Environment

macOS (Darwin 25.3.0, arm64)
Homebrew at /opt/homebrew/bin (Apple Silicon default)
git-lfs 3.6.1 installed at /opt/homebrew/bin/git-lfs
Repo has Git LFS filters configured globally: filter.lfs.required = true, plus filter=lfs entries in .gitattributes
What happened Calling mcp__harness-control__create_worktree returns HTTP 500:

Command failed: git worktree add ...
Preparing worktree (new branch '...')
git-lfs filter-process: git-lfs: command not found
fatal: the remote end hung up unexpectedly
Root cause The subprocess that Harness spawns for git worktree add doesn't have /opt/homebrew/bin on its PATH. Git's LFS filter (filter.lfs.process = git-lfs filter-process) then can't locate the git-lfs binary, and because filter.lfs.required = true, the checkout aborts, taking the whole worktree add down with it.

The PATH seen by Harness's subprocesses is:

/usr/bin:/bin:/usr/sbin:/sbin:/usr/local/bin:
Note the absence of /opt/homebrew/bin. This is macOS's default GUI-app PATH — apps launched from Finder / Launch Services don't source ~/.zshrc or ~/.zprofile, so any user-added PATH entries are lost.

Why the parent Claude Code session isn't affected Bash tool calls inside Claude Code inherit the same trimmed PATH, but they don't invoke git worktree add on this repo — only Harness's own worktree code path does. Any LFS-required checkout would fail the same way (e.g. cloning a fresh copy from Harness would too).

Proposed fixes (any one works)

Harness should launch git subprocesses with PATH from the user's login shell — e.g. /bin/zsh -lic 'git worktree add ...' or explicitly source ~/.zprofile / ~/.zshrc.
Alternatively, prepend the common Homebrew locations (/opt/homebrew/bin, /usr/local/bin) to the child-process PATH in Harness itself.
As a workaround for users: symlink sudo ln -s /opt/homebrew/bin/git-lfs /usr/local/bin/git-lfs (fragile; breaks on Homebrew upgrades that relocate binaries).
Repro

Install git-lfs via brew install git-lfs on an Apple Silicon Mac.
Launch Harness from Finder (not from a terminal).
Open a repo that uses LFS (has filter.lfs.required = true).
Call create_worktree — fails.
Confirm the missing PATH by running echo $PATH from a shell spawned via Harness — no /opt/homebrew/bin.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions