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

Plugin does not set path properly. Preferences system binaries over nix installed ones. #19

Closed
drewboardman opened this issue Feb 29, 2020 · 5 comments

Comments

@drewboardman
Copy link

Issue: system packages are being preferred while in nix shell.

Description: Here is the result of checking out my PATH.

~/code/fp-course (master*) $ (nix-shell) > tr : $'\n' <<<"$PATH"
/home/myUser/.nix-profile/bin
/home/myUser/.jenv/shims
/home/myUser/code/lib/.jenv/bin
/home/myUser/.cabal/bin
/home/myUser/.local/bin
/home/myUser/.oh-my-zsh/custom/plugins/nix-shell/scripts
/nix/store/s7p0wfbdfbq307zgifhnh6w8sfjvy64y-patchelf-0.9/bin
/nix/store/ghzg4kg0sjif58smj2lfm2bdvjwim85y-gcc-wrapper-7.4.0/bin
/nix/store/d4n93jn9fdq8fkmkm1q8f32lfagvibjk-gcc-7.4.0/bin
/nix/store/f5wl80zkrd3fc1jxsljmnpn7y02lz6v1-glibc-2.27-bin/bin
/nix/store/d9s1kq1bnwqgxwcvv4zrc36ysnxg8gv7-coreutils-8.30/bin
/nix/store/rbpyfy6413aqpik9aj6p3a2syd1mda68-binutils-wrapper-2.31.1/bin
/nix/store/0y7jmqnj48ikjh37n3dl9kqw9hnn68nq-binutils-2.31.1/bin
/nix/store/f5wl80zkrd3fc1jxsljmnpn7y02lz6v1-glibc-2.27-bin/bin
/nix/store/d9s1kq1bnwqgxwcvv4zrc36ysnxg8gv7-coreutils-8.30/bin
/nix/store/8vq01xmxlp9wxzilkw85rb621ag7nwmd-ghc-8.6.4/bin
/nix/store/ghzg4kg0sjif58smj2lfm2bdvjwim85y-gcc-wrapper-7.4.0/bin
/nix/store/d4n93jn9fdq8fkmkm1q8f32lfagvibjk-gcc-7.4.0/bin
/nix/store/f5wl80zkrd3fc1jxsljmnpn7y02lz6v1-glibc-2.27-bin/bin
/nix/store/d9s1kq1bnwqgxwcvv4zrc36ysnxg8gv7-coreutils-8.30/bin
/nix/store/rbpyfy6413aqpik9aj6p3a2syd1mda68-binutils-wrapper-2.31.1/bin
/nix/store/0y7jmqnj48ikjh37n3dl9kqw9hnn68nq-binutils-2.31.1/bin
/nix/store/f5wl80zkrd3fc1jxsljmnpn7y02lz6v1-glibc-2.27-bin/bin
/nix/store/d9s1kq1bnwqgxwcvv4zrc36ysnxg8gv7-coreutils-8.30/bin
/nix/store/k7gx5pr1mf0zrq93g7sfhy4s5rxh7gpz-ghcid-0.7.2/bin
/nix/store/k0y9nrym785l61pjw0lp0qk90v2nbpqs-ncurses-6.1-20190112/bin
/nix/store/d9s1kq1bnwqgxwcvv4zrc36ysnxg8gv7-coreutils-8.30/bin
/nix/store/krhqmaqal0gklh15rs2bwrqzz8mg9lrn-findutils-4.6.0/bin
/nix/store/pmzw4y4465zmq0dc8r4xbwyrqsaj4s70-diffutils-3.7/bin
/nix/store/x1khw8x0465xhkv6w31af75syyyxc65j-gnused-4.7/bin
/nix/store/wnjv27b3j6jfdl0968xpcymlc7chpqil-gnugrep-3.3/bin
/nix/store/vvwggp5mni64yavsfqmbwvm1mn692ssn-gawk-4.2.1/bin
/nix/store/wmxqm38g1y1y7sd7s9vg7an3klffaiyz-gnutar-1.31/bin
/nix/store/ix2q5vnynzfgsi4nqj8pmcbx2kf78wrm-gzip-1.10/bin
/nix/store/q6821d46lc5514rfh537c20f9ay2760l-bzip2-1.0.6.0.1-bin/bin
/nix/store/8n7v99ii7cg694pz0cfch422zvkdqfv4-gnumake-4.2.1/bin
/nix/store/cinw572b38aln37glr0zb8lxwrgaffl4-bash-4.4-p23/bin
/nix/store/jl17v3f872ax5wfi49b04mjzjz10rnra-patch-2.7.6/bin
/nix/store/zrazw25gy012ip7vcqddw6lcc393qvcg-xz-5.2.4-bin/bin
/home/myUser/.nix-profile/bin
/home/myUser/.jenv/shims
/home/myUser/code/lib/.jenv/bin
/home/myUser/.nvm/versions/node/v13.6.0/bin
/home/myUser/.cabal/bin
/home/myUser/.local/bin
/home/myUser/.nix-profile/bin
/home/myUser/.nix-profile/bin
/nix/var/nix/profiles/default/bin
/opt/google-cloud-sdk/bin
/usr/local/bin
/usr/local/sbin
/usr/bin
/usr/lib/jvm/default/bin
/usr/bin/site_perl
/usr/bin/vendor_perl
/usr/bin/core_perl

The /nix/store/ binaries are under my system binaries. This does not happen when I remove the plugin. Here is the repeated example without the pluging.

drew@muaddib ~/code/fp-course (master*) $ nix-shell
warning: Nix search path entry '/nix/var/nix/profiles/per-user/root/channels' does not exist, ignoring
warning: Nix search path entry '/nix/var/nix/profiles/per-user/root/channels/nixpkgs' does not exist, ignoring

[nix-shell:~/code/fp-course]$ tr : $'\n' <<<"$PATH"
/nix/store/c0hwk342ic9vajxpzar9rsz73k4wqbhi-bash-interactive-4.4-p23/bin
/nix/store/s7p0wfbdfbq307zgifhnh6w8sfjvy64y-patchelf-0.9/bin
/nix/store/ghzg4kg0sjif58smj2lfm2bdvjwim85y-gcc-wrapper-7.4.0/bin
/nix/store/d4n93jn9fdq8fkmkm1q8f32lfagvibjk-gcc-7.4.0/bin
/nix/store/f5wl80zkrd3fc1jxsljmnpn7y02lz6v1-glibc-2.27-bin/bin
/nix/store/d9s1kq1bnwqgxwcvv4zrc36ysnxg8gv7-coreutils-8.30/bin
/nix/store/rbpyfy6413aqpik9aj6p3a2syd1mda68-binutils-wrapper-2.31.1/bin
/nix/store/0y7jmqnj48ikjh37n3dl9kqw9hnn68nq-binutils-2.31.1/bin
/nix/store/f5wl80zkrd3fc1jxsljmnpn7y02lz6v1-glibc-2.27-bin/bin
/nix/store/d9s1kq1bnwqgxwcvv4zrc36ysnxg8gv7-coreutils-8.30/bin
/nix/store/8vq01xmxlp9wxzilkw85rb621ag7nwmd-ghc-8.6.4/bin
/nix/store/ghzg4kg0sjif58smj2lfm2bdvjwim85y-gcc-wrapper-7.4.0/bin
/nix/store/d4n93jn9fdq8fkmkm1q8f32lfagvibjk-gcc-7.4.0/bin
/nix/store/f5wl80zkrd3fc1jxsljmnpn7y02lz6v1-glibc-2.27-bin/bin
/nix/store/d9s1kq1bnwqgxwcvv4zrc36ysnxg8gv7-coreutils-8.30/bin
/nix/store/rbpyfy6413aqpik9aj6p3a2syd1mda68-binutils-wrapper-2.31.1/bin
/nix/store/0y7jmqnj48ikjh37n3dl9kqw9hnn68nq-binutils-2.31.1/bin
/nix/store/f5wl80zkrd3fc1jxsljmnpn7y02lz6v1-glibc-2.27-bin/bin
/nix/store/d9s1kq1bnwqgxwcvv4zrc36ysnxg8gv7-coreutils-8.30/bin
/nix/store/k7gx5pr1mf0zrq93g7sfhy4s5rxh7gpz-ghcid-0.7.2/bin
/nix/store/k0y9nrym785l61pjw0lp0qk90v2nbpqs-ncurses-6.1-20190112/bin
/nix/store/d9s1kq1bnwqgxwcvv4zrc36ysnxg8gv7-coreutils-8.30/bin
/nix/store/krhqmaqal0gklh15rs2bwrqzz8mg9lrn-findutils-4.6.0/bin
/nix/store/pmzw4y4465zmq0dc8r4xbwyrqsaj4s70-diffutils-3.7/bin
/nix/store/x1khw8x0465xhkv6w31af75syyyxc65j-gnused-4.7/bin
/nix/store/wnjv27b3j6jfdl0968xpcymlc7chpqil-gnugrep-3.3/bin
/nix/store/vvwggp5mni64yavsfqmbwvm1mn692ssn-gawk-4.2.1/bin
/nix/store/wmxqm38g1y1y7sd7s9vg7an3klffaiyz-gnutar-1.31/bin
/nix/store/ix2q5vnynzfgsi4nqj8pmcbx2kf78wrm-gzip-1.10/bin
/nix/store/q6821d46lc5514rfh537c20f9ay2760l-bzip2-1.0.6.0.1-bin/bin
/nix/store/8n7v99ii7cg694pz0cfch422zvkdqfv4-gnumake-4.2.1/bin
/nix/store/cinw572b38aln37glr0zb8lxwrgaffl4-bash-4.4-p23/bin
/nix/store/jl17v3f872ax5wfi49b04mjzjz10rnra-patch-2.7.6/bin
/nix/store/zrazw25gy012ip7vcqddw6lcc393qvcg-xz-5.2.4-bin/bin
/home/drew/.nix-profile/bin
/home/drew/.jenv/shims
/home/drew/code/lib/.jenv/bin
/home/drew/.nvm/versions/node/v13.6.0/bin
/home/drew/.cabal/bin
/home/drew/.local/bin
/home/drew/.nix-profile/bin
/home/drew/.nix-profile/bin
/nix/var/nix/profiles/default/bin
/opt/google-cloud-sdk/bin
/usr/local/bin
/usr/local/sbin
/usr/bin
/usr/lib/jvm/default/bin
/usr/bin/site_perl
/usr/bin/vendor_perl
/usr/bin/core_perl

As you can see, the nix/store/ binaries are at the top (as expected).

One example of this being an issue is

    $ which ghcid
    /home/myUser/.local/bin/ghcid

Here is my zshrc file.


To reproduce:

  1. Clone this repo.

  2. run ./support/copy-tool-files.sh

  3. enter nix-shell

  4. check your PATH (nice printing with tr : $'\n' <<<"$PATH")


As you can see, this plugin is doing something to re-create the path in such a way that system bins are on top.

@chisui
Copy link
Owner

chisui commented Mar 9, 2020

This happens since the the plugin uses the normal zshrc to initialize the shell. When using bash nix replaces that file. So if you prepend entries to your PATH inside of your zshrc they will take precedence.

Since this plugin is meant to provide a customizable working environment loading some rc file is pretty much required.

Maybe the plugin could load a custom zshrc.nix-shell file or something like that if it is present. So you could include all the setup you want to happen for your nix-shell in there and source it in your actual zshrc.

@drewboardman
Copy link
Author

Yeah, it seems unfortunate to need to maintain a separate bashrc that has some/all the functionality of zsh - just for use with nix-shell.

@softinio
Copy link

softinio commented Apr 4, 2020

Yup this is affecting my work too. Subscribed to this thread and will pause using this plugin till we have a solution. Thank you for a great plugin hope this quirk has a solution.

@9viz
Copy link

9viz commented Apr 28, 2020

I ported this plugin to my mksh config and I don't have this issue. I think the issue arises because you, probably, set environment variables in zshrc. Setting your env vars in profile might be a solution which is what I do. Setting PATH in zprofile (or profile if zsh sources it) should fix the issue.

@chisui
Copy link
Owner

chisui commented Apr 30, 2020

Reading through the documentation .zlogin or .zsprofile seem to be the solution here. Building something into this plugin that could be achieved using default zsh features seems like a bad idea to me.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants