Nix develop vs nix develop -i

hey hey,

It seems like on my mac, nix develop does not work as intended. Or at least, what I understand of its intents. With the simple flake example here: Nix By Example | <fun> if I launch nix develop -i and do which gcc it shows me the one from the nix store, but if I do nix develop it shows me the system gcc.

I dumped env on both nix develop and nix develop -i and the first one does not have any nix store in the PATH, while the latter has the /nix/store gcc in front of the PATH.

Am I missing something? Or is there potentially something on my computer that resets the PATH after nixes sets it correctly?

1 Like

Very likely this. nix develop -i is clearing away some environment variable that’s triggering it in the other case, would be my guess.

1 Like

Any idea on how I could investigate this?

I would start by looking into the documentation for your shell and find out what it sources on startup, then look at those scripts and see if you see anything obvious.

1 Like

If you’re having trouble following the source directly, you can edit the first file to add a “set -x”, which will cause it to print statements as it executes them.



  • I added that in my .bashrc and .bash_profile and it didn’t yield anything when I open a new terminal. I was under the impression that these would always get executed.
  • On the other hand that line works in my .zshrc (but I get a million lines).
  • if I do nix develop then it only executes .bashrc

It turns out that it was this line that was removing all the /nix/store things in my PATH:

eval “$(direnv hook zsh)”

anyone knows why : c ? In any case thanks a lot for the help, I think this fixed all my issues!

1 Like