I am running into a strange problem on Apple ARM macOS 14.7.1.
Whenever I’m inside a Nix shell, gcc becomes inaccessible.
Steps to reproduce:
nix-shell -p pkg-config
gcc --version
$ gcc --version
error: tool 'gcc' not found
Notably, on the same machine, gcc --version outside of a Nix shell give the expected output.
$ gcc --version
Apple clang version 16.0.0 (clang-1600.0.26.4)
Target: arm64-apple-darwin23.6.0
Thread model: posix
InstalledDir: /Library/Developer/CommandLineTools/usr/bin
This problem persists even after I factory-reset the laptop and install Nix from scratch. I’ve tried this several times now.
Notably, I have not been able to reproduce the problem on a different Apple ARM macOS Sonoma 14.7.1 machine I own. Installing Nix from scratch on that machine, entering a Nix shell, and issuing the gcc --version command gives the expected output.
clang version 16.0.6
Target: arm64-apple-darwin
Thread model: posix
InstalledDir: /nix/store/44hqr4414m3jldixkm4cq47q5pnpy83d-clang-16.0.6/bin
Do you have Xcode installed on one machine but not the other? That GCC version is for the Clang alias found in the Xcode toolchain via the /usr/bin/gcc stub. If you don’t have Xcode (or the command-line tools) installed, you’ll get an error about a missing gcc tool.
I would definitely check whether you’re using the same Nixpkgs revision on both machines, then. If you update the channel on both I expect it’ll start working on both.
That’s almost certainly the problem. Thanks, very much, Emily. (Admittedly, I haven’t tested it. When I nix-shell with the staging channel, it tries to build and test the universe and eventually some tests fail. I didn’t have much time to look into it further.)