BUG: Turbo crashes with EISDIR when GIT_DIR is set in a git worktree
#12573
Unanswered
bestickley
asked this question in
Help
Replies: 0 comments
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
-
Summary
Turbo crashes with
EISDIRwhenGIT_DIRis set in a git worktreeDescription
turbo runfails withI/O error: Is a directory (os error 21)when executed inside a git hook in a git worktree. The error occurs during the file hashing phase before any tasks are started.Environment
Reproduction
Create a git worktree from a turborepo monorepo:
Run turbo with
GIT_DIRset to the worktree's git directory (this is what git does automatically during hook execution):GIT_DIR=$(git rev-parse --git-dir) npx turbo run buildTurbo crashes:
Running the same command without
GIT_DIRset works fine:npx turbo run build # ✅ worksRoot Cause
In a git worktree,
git rev-parse --git-dirreturns a path like:This directory contains subdirectories (
refs/,logs/) that don't exist in a normal.gitdirectory. WhenGIT_DIRis set, Turbo appears to use it directly for worktree/SCM detection and attempts to read a file at a path that is actually a directory.The error happens during the
turborepo_scm::package_depsphase — after all glob/ignore processing but before any task processes are spawned (debug logs showwaiting for 0 processes to exit).Impact
This breaks all git hooks (pre-commit, pre-push, etc.) that invoke
turboin a worktree, because git automatically setsGIT_DIRwhen executing hooks.Workaround
Unset
GIT_DIRbefore calling turbo in the hook:This is safe because turbo (and git) will discover the repo by walking up from
cwdand reading the.gitfile'sgitdir:pointer, arriving at the same location.Additional Context
--dry-runworks fine (doesn't trigger the code path)--ui=streamdoes not fix it (the error is in SCM detection, not the TUI)git hashing failed ... Falling back to manualmessages for every package, but the fatalEISDIRerror is not captured in the debug log — it occurs at a lower level in Turbo's Rust I/O layerAdditional information
No response
Example
No response
Beta Was this translation helpful? Give feedback.
All reactions