Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

PATH should prioritize user defined packages #38657

Open
fkorotkov opened this issue Apr 9, 2018 · 5 comments
Open

PATH should prioritize user defined packages #38657

fkorotkov opened this issue Apr 9, 2018 · 5 comments
Labels
2.status: stale https://github.com/NixOS/nixpkgs/blob/master/.github/STALE-BOT.md 6.topic: darwin Running or building packages on Darwin 6.topic: developer experience

Comments

@fkorotkov
Copy link

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.

@matthewbauer
Copy link
Member

/cc @Ericson2314 who knows about this stdenv stuff

Here's the full PATH if it helps:

/nix/store/8b0gj3bmcy5bh1zcnhn0146199b3m5kb-clang-wrapper-5.0.1/bin:/nix/store/p85m242dg1zd85ln3cg0agx0q1n0n6h0-clang-5.0.1/bin:/nix/store/5lkrw9dnsgy62qm1ampvww1c5n1pdm4b-coreutils-8.29/bin:/nix/store/jxmp27m26646f67faji9v94d5471ma8y-cctools-binutils-darwin-wrapper/bin:/nix/store/kdff2gim6417493yha769kh00n63lnrw-cctools-binutils-darwin/bin:/nix/store/5lkrw9dnsgy62qm1ampvww1c5n1pdm4b-coreutils-8.29/bin:/nix/store/w1yz6kn58cg6qm9d4by3ldihg2ki3wr0-shell_cmds-osx-10.11.6/bin:/nix/store/5lkrw9dnsgy62qm1ampvww1c5n1pdm4b-coreutils-8.29/bin:/nix/store/lzrwadp3l7np2734jxzqmxsgnjqfy4m7-findutils-4.6.0/bin:/nix/store/jrcykkx415grrjvrrhvs8hgl6pvj6x5b-diffutils-3.6/bin:/nix/store/llk6iyb3ppvyaflbkg5rbv960wlsxpkc-gnused-4.4/bin:/nix/store/c3sa761qjcaa5rg0s8h8qxj0mghkidv5-gnugrep-3.1/bin:/nix/store/gpp9x3ninvcw6m2n5m075q8nckzmcv09-gawk-4.2.1/bin:/nix/store/m88jhn3qgiz48zdllhpvgkz1ricmh89m-gnutar-1.30/bin:/nix/store/61bqs4awrycwdiaz7yb3bxvbyja1ghxr-gzip-1.9/bin:/nix/store/7vldi2061ga9phyhkr3sin8fk2kpc6sl-bzip2-1.0.6.0.1-bin/bin:/nix/store/y2nxw92is8125gdng3bsv23isray1g9m-gnumake-4.2.1/bin:/nix/store/r8bx3qf1bpncb14i9gzma4vr089pc3pv-bash-4.4-p19/bin:/nix/store/l1d4iaik29pkg7pdng7iw8ch75h71n36-patch-2.7.6/bin:/nix/store/03x40jq9ik0j4br0k2jmn288hz25589l-xz-5.2.3-bin/bin

It appears to be macOS only.

@Ericson2314
Copy link
Member

Yeah the way we do these sorts of things is all screwed up.

@Ericson2314
Copy link
Member

#31414 started to fix it but I ran into errors with libcs and the like. Yet another thing that would be easier if compilers never built their own libraries.

matthewbauer added a commit to matthewbauer/nix that referenced this issue Oct 31, 2018
Now the nix-shell will generate a nix expression that looks like this:

with import <nixpkgs> {};
runCommand "shell" {
  nativeBuildInputs = [
    (...)
    (...)
    (...)
  ];
}

from

$ nix-shell --packages ... ... ...

Fixes the issue described in NixOS/nixpkgs#38657.
matthewbauer added a commit to matthewbauer/nix that referenced this issue Oct 31, 2018
Now the nix-shell will generate a nix expression that looks like this:

with import <nixpkgs> {};
runCommand "shell" {
  nativeBuildInputs = [
    (...)
    (...)
    (...)
  ];
}

from

$ nix-shell --packages ... ... ...

Fixes the issue described in NixOS/nixpkgs#38657.
@matthewbauer
Copy link
Member

I think the core issue is just that we always process native build inputs (even default ones) before buildInputs. I think the easiest solution is to just use nativeBuildInputs here. I've opened a PR to fix this in nix-shell:

NixOS/nix#2504

@stale
Copy link

stale bot commented Jun 3, 2020

Thank you for your contributions.

This has been automatically marked as stale because it has had no activity for 180 days.

If this is still important to you, we ask that you leave a comment below. Your comment can be as simple as "still important to me". This lets people see that at least one person still cares about this. Someone will have to do this at most twice a year if there is no other activity.

Here are suggestions that might help resolve this more quickly:

  1. Search for maintainers and people that previously touched the related code and @ mention them in a comment.
  2. Ask on the NixOS Discourse.
  3. Ask on the #nixos channel on irc.freenode.net.

@stale stale bot added the 2.status: stale https://github.com/NixOS/nixpkgs/blob/master/.github/STALE-BOT.md label Jun 3, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
2.status: stale https://github.com/NixOS/nixpkgs/blob/master/.github/STALE-BOT.md 6.topic: darwin Running or building packages on Darwin 6.topic: developer experience
Projects
None yet
Development

No branches or pull requests

4 participants