Missing system dev tools when running nix develop on MacOS #649
Labels
No labels
Affects/CppNix
Affects/Nightly
Affects/Only nightly
Affects/Stable
Area/build-packaging
Area/cli
Area/evaluator
Area/fetching
Area/flakes
Area/language
Area/lix ci
Area/nix-eval-jobs
Area/profiles
Area/protocol
Area/releng
Area/remote-builds
Area/repl
Area/repl/debugger
Area/store
bug
Context
contributors
Context
drive-by
Context
maintainers
Context
RFD
crash 💥
Cross Compilation
devx
docs
Downstream Dependents
E/easy
E/hard
E/help wanted
E/reproducible
E/requires rearchitecture
imported
Language/Bash
Language/C++
Language/NixLang
Language/Python
Language/Rust
Needs Langver
OS/Linux
OS/macOS
performance
regression
release-blocker
stability
Status
blocked
Status
invalid
Status
postponed
Status
wontfix
testing
testing/flakey
Topic/Large Scale Installations
ux
No milestone
No project
No assignees
2 participants
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference: lix-project/lix#649
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Describe the bug
I use simple fake files to configure development environments. Before running
nix develop
, command like tools likegit
are available and work as expected. After runningnix develop
, I get and error likeerror: tool 'git' not found
. This is true for other tools likegcc
as well.Steps To Reproduce
flake.nix
with the following content:nix develop
git --version
and see the errorerror: tool 'git' not found
Expected behavior
I'd expect any program already installed on my computer to work inside a nix development shell.
nix --version
outputnix --version
nix (Lix, like Nix) 2.92.0
System type: aarch64-darwin
Additional system types:
Features: gc, signed-caches
System configuration file: /etc/nix/nix.conf
User configuration files: /Users/aaron/.config/nix/nix.conf:/etc/xdg/nix/nix.conf
Store directory: /nix/store
State directory: /nix/var/nix
Data directory: /nix/store/y9mgqlvgyh0ixd0vgyn1y4kjgsn2gw36-lix-2.92.0/share
Additional context
Running MacOS 15.2 (Sequoia) on a M4 MacbookPro. I haven't yet installed
nix-darwin
.Sadly I can't reproduce this. Can you
echo $PATH
inside that nix shell?Another thing that is really curious about that error message is that that is not an error message emitted by zsh or bash.
This leads me to believe that somehow this is hitting xcode, since I think that xcode has this idea of "tools" as per the error you mentioned. There is a bug with the shell initialization on macOS that has surely been there for practically years (#645) which causes the various Nix profiles to get shoved at the start of PATH all the time such that they override whatever is included in the
nix shell
/nix develop
. That might be a contributing cause?Thanks for the reply @jade. Here's a copy paste of a couple commands and my PATH. Yes, it does seem like something is going wrong with how the developer tools are shimmed and resolved when you run them. i.e. zsh seems to know about
git
, but when you try to rungit
something breaks along the way.I'll try to make sense of that PATH value asap and chime in with any thoughts here.
Here is PATH with some line breaks:
Out of curiosity, just did a fresh install of MacOS Ventura on a different computer (vs Sequoia in my original post). Fresh OS install, installed Lix, installed the command line tools using
xcode-select --install
, the configured and ran my flake usingnix develop
... Same error witherror: tool 'git' not found
.Ok, I have things working, but I don't understand why.
I noticed that when I was not in a nix development environment,
xcode-select --print-path
returned/Library/Developer/CommandLineTools
.When I was in a nix development environment, the same command returned
/nix/store/6py65dicilvc6qxfra4mzw0xpxw2vc06-apple-sdk-11.3
.Digging into that nix store folder for
apple_sdk
, I could see many commands were exist in/Library/Developer/CommandLineTools
were missing inapple_sdk
(including the one I was testing with,git
).Out of curiosity, in the nix environment, I ran
xcode-select --switch /Library/Developer/CommandLineTools
, and thengit
and other commands were working fine.Strangely, I can now exit the nix developer shell, and restart it, and NOT run
xcode-select --switch
, and things continue to work. If I do runxcode-select --print-path
in the nix shell, it still prints/nix/store/6py65dicilvc6qxfra4mzw0xpxw2vc06-apple-sdk-11.3
, but for whatever reason, other commands continue to work.Like I said, I don't understand this, but I'll happily take it. Seems like something about how MacOS and nix are interacting to resolve the Apple developer command line tools was somehow straightened out by running
xcode-select --switch /Library/Developer/CommandLineTools
that single time.I wonder, try grepping the output of
env
for the xcode developer tools store path for nixpkgs' weird ones (the one that doesn't have git in it). It's probably some environment variable overriding the path xcode is using.I also find this happens if I run
lldb
in the lix repo's dev shell. beats me as to why.