Skip to content

--run-env puts my ~/.nix-profile/bin in PATH first? #124

Closed

Description

@zefhemel

When I run nix-build --run-env and then echo my PATH:

bash-3.2$ echo $PATH
/Users/zef/.nix-profile/bin:/nix/store/y72fcnh1x4f5madms9yrlndcd42m36bm-nodejs-0.10.7/bin:...

That is: my nix profile's bin directory appears first in my path, before the directories of my explicitly specified dependencies. Therefore my own version of node (in this case) takes precedence over the one I specified in my build file. That doesn't shouldn't be the case right?

This is the expression I'm using.

Activity

  1. zefhemel commented on May 29, 2013

    @zefhemel
    Author

    It looks like this issue arises from here: https://github.com/NixOS/nix/blob/master/scripts/nix-build.in#L176

    In the comment it says it's useful to still have the current programs in $PATH be available, and I agree, but perhaps the PATH generated from the expression should be prepended to the user's one somehow?

  2. edolstra commented on May 29, 2013

    @edolstra
    Member

    It is prepended:

    my $envCommand = "p=\$PATH; source \$stdenv/setup; PATH=\$PATH:\$p; exec $shell";
    

    I.e. the user's $PATH is saved to $p, then appended to the new $PATH. This works for me. Maybe you're adding ~/.nix-profile/bin to $PATH in ~/.bashrc rather than ~/.bash_profile?

  3. zefhemel commented on May 29, 2013

    @zefhemel
    Author

    Heh, indeed when I remove my ~/.bashrc (which I wasn't even aware I had), the issue is fixed. Thanks! Closing.

  4. added a commit that references this issue on Jan 1, 2024
  5. added a commit that references this issue on Jul 11, 2024
    11f35af
  6. added a commit that references this issue on Jul 25, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions