Repository navigation
Description
On macOS, running git inside any nix develop shell fails:
nix develop .#kotlin -c git --version
error: tool 'git' not foundThis affects the default shell too, which means anyone using the repo's .envrc (use flake .) has no working git in the project directory until they leave the shell. .#release is the only shell that works, because it's the only one that lists git in its packages.
why this happens is because /usr/bin/git on macOS is not git — it's Apple's xcode-select shim, which locates the real binary via DEVELOPER_DIR when that variable is set, falling back to xcode-select -p when it isn't.
Nix's Darwin stdenv sets DEVELOPER_DIR to its own pinned Apple SDK so that compilers and linkers don't depend on whatever Xcode is installed on the host:
DEVELOPER_DIR=/nix/store/d8s89pc5...-apple-sdk-14.4
That SDK ships only xcrun — no git. So the shim looks inside it, finds nothing, and emits Apple's error. /usr/bin/git is still first on PATH; it just can't resolve a real binary anymore.
the shim is the problem, not the absence of git:
nix develop .#kotlin -c env -u DEVELOPER_DIR git --version
git version 2.54.0 (Apple Git-157)nix develop .#kotlin -c /Library/Developer/CommandLineTools/usr/bin/git --version
git version 2.54.0 (Apple Git-157)the SDK nix points DEVELOPER_DIR at contains only xcrun:
nix develop .#kotlin -c bash -c 'ls $DEVELOPER_DIR/usr/bin'
xcrunfix i'm proposing
Add git to each dev shell's packages, the way releaseDevShell already does. nix's git then precedes /usr/bin on PATH, so the shim is never consulted. the crane devShell definition is shared, so the first change covers default/nightly/stable/msrv. nix's git also ships git-credential-osxkeychain, so the macOS keychain credential helper keeps working.
crane shells (default/nightly/stable/msrv):
packages =
with pkgs;
[
cargo-edit
cargo-nextest
cargo-watch
rust-analyzer
cargo-fuzz
bzip2 # needed for some machines to have access to libzip at runtime
codespell
+ git
]
++ pkgs.lib.optionals (!pkgs.stdenv.isDarwin) [
cargo-llvm-cov
];javascriptDevShell:
llvmPackages.clang-unwrapped
llvmPackages.bintools-unwrapped
lld
bzip2 # needed for some machines to have access to libzip at runtime
+ git
];dartDevShell:
[
rustVersions.msrv
dart
bzip2
curl
jq
+ git
]same flow for csharpDevShell, kotlinDevShell and pythonDevShell
I've got a branch with the diffs applied and i can open a PR if this is worth fixing now? let me know what you guys think.
environment:
- macOS 27.0, aarch64-darwin (apple silicon)
- Determinate Nix 3.21.8 (nix 2.34.8)
- apple-sdk-14.4 (what DEVELOPER_DIR resolves to inside the shells)
Activity
xstoicunicornx commentedon Sep 29, 2026
I think it could be worth adding to crane shells. I am not as sure about adding it to the bindings shells? What do we need git for in there?
I haven't run into this issue myself, I am on macOS 15 darwin.
AdamuAbba commentedon Oct 5, 2026
Hey @xstoicunicornx, thanks for taking a look! you're right, the bindings shells don't need git since we just enter them to build or test the bindings and leave. I'll limit the change to the crane shells.
On why you might not be seeing it: the bug triggers when the first git on PATH is Apple's
/usr/bin/gitshim. If you have git from Homebrew or elsewhere earlier on your PATH, the shim is never used. Could you checknix develop -c which -a git? On my machine it resolves to/usr/bin/git, so afterdirenv allowI lose git, and afterdirenv denyit comes back.xstoicunicornx commentedon Oct 13, 2026
Hey @AdamuAbba , sorry for delay in getting back to you. I still can't seem to replicate what you are seeing. Here is what I get:
Just to confirm, running
nix develop -c git --versionerrors for you still? I'd like to pin down what the issue actually is before we move forward with updates.AdamuAbba commentedon Oct 19, 2026
Hey @xstoicunicornx, thanks for testing. Yes, it still fails for me. Here's what i get:
$ nix develop -c git --version evaluation warning: crane requires at least nixpkgs-26.05, supplied nixpkgs-25.11 error: tool 'git' not foundOn my machine (macOS 27.0.1),
/usr/bin/gitis a macOS stub that, whenDEVELOPER_DIRis set, runs$DEVELOPER_DIR/usr/bin/xcrun. In the nix SDK that's xcbuild'sxcrun, which prints the error. Since both of your commands gave the same result, either your stub behaves differently orDEVELOPER_DIRisn't set in your shell. This check needs no nix:Mine prints
fake xcrun called with: git --version. Could you share its output andnix develop -c bash -c 'echo $DEVELOPER_DIR'? You mentioned you're on macOS 15, so if the check prints a git version, it's likely a macOS version difference. If it matches mine, the difference is in your nix shell.Here's a flow diagram explaining the check i'd like you to run above:
xstoicunicornx commentedon Oct 19, 2026
My outputs are below, seems to be something nix related then? What do you get for
nix develop -c bash -c 'echo $DEVELOPER_DIR'?AdamuAbba commentedon Oct 25, 2026
Thanks @xstoicunicornx Mine's actually the same path:
$ nix develop -c bash -c 'echo $DEVELOPER_DIR' /nix/store d8s89pc5y7r8l09pgz3s80s2igqga9ir-apple-sdk-14.4So it isn't nix: same SDK, and your stub hands off to
xcrunlike mine does. That leaves which git is found first.nix developkeeps your existingPATHafter its own entries, and in the shell mine only finds the stub:My guess is you have a real git (maybe Xcode's
Contents/Developer/usr/bin) earlier on yourPATH, so the stub never runs. Could you share what you get when you run thisnix develop -c which -a git?xstoicunicornx commentedon Nov 2, 2026
I still get the same as you :/
AdamuAbba commentedon Nov 4, 2026
Hey @xstoicunicornx Thanks for testing this. At least that rules out my
PATHguess. Since you can't reproduce it and it depends on local setup, I'm happy to install git through Homebrew on my end and move on. should I close this issue and #1969, or would you rather I leave them open?For anyone else who hits
error: tool 'git' not foundin the dev shell on macOS: nix'sxcrundoesn't search/usr/binand falls back to the/var/select/developer_dirand/var/db/xcode_select_linksymlinks.If neither exists and
/usr/bin/gitis your first git onPATH, git fails. Installing git separately or runningsudo xcode-select -s /Applications/Xcode.app/Contents/Developershould fix it but i'd advice installing git separately.xstoicunicornx commentedon Nov 12, 2026
You did all the real testing, thank you! I think lets just add to the crate, just to ensure no one else runs into this. Its very small change that doesn't cost much.