Skip to content

PATH should prioritize user defined packages #38657

@fkorotkov

Description

@fkorotkov

When I'm trying to run a script using nix-shell, $PATH contains several folders starting with coreutils from standard environment:

$: nix-shell --packages darwin.shell_cmds --pure --run "echo \$PATH"
/nix/store/s28xb9v7xf6axvf4a3av2mnczws2hsdg-coreutils-8.29/bin:/nix/store/j2z3v4g8y39ph0z03mh2cv2xaqvfmrai-shell_cmds-osx-10.11.6/bin

Unfortunately, since coreutils is in front, it will be looked into first. That means, in case of a conflict, binaries from coreutils will always be picked.

In the case above, shell_cmds contains mktemp for Mac OS which is slightly different from GNU's one, but there is no easy way to make the script inside nix-shell to use mktemp from shell_cmds.

I think a solution here is to always put packages defined by user in front of the PATH and put all the default stuff in the end.

Metadata

Metadata

Assignees

No one assigned

    Labels

    2.status: stalehttps://github.com/NixOS/nixpkgs/blob/master/.github/STALE-BOT.md6.topic: darwinRunning or building packages on Darwin6.topic: developer experiencenixpkgs development workflow
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions