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

nix-shell, as interpreter, seems to follow symlinks looking for {shell|default}.nix #2150

Closed
chreekat opened this issue May 10, 2018 · 4 comments

Comments

@chreekat
Copy link
Contributor

Consider this log, where a trivial setup works fine, unless the script is a symlink:

$ cat default.nix
{ }:
with (import <nixpkgs> {});
runCommand "test" { buildInputs = [ pkgs.hello ]; } ""

$ cat test.sh
#!/usr/bin/env nix-shell
#! nix-shell --pure -i bash
hello

$ ./test.sh
Hello, world!

$ mv test.sh aa && ln -s aa/test.sh

$ ./test.sh
error: getting status of ‘/home/b/tmp/nix-shell-interpreter/aa/default.nix’: No such file or directory

Expected behavior

It surprised me that the symlink was followed. My scenario is that certain scripts are located in one location, but I would like to use them in the context of another location. Symlinks seem like a reasonable way to do this. But maybe I could be convinced otherwise.

Info

  • system: "x86_64-linux"
  • host os: Linux 4.9.86, NixOS, 17.09.3243.bca2ee28db4 (Hummingbird)
  • multi-user?: yes
  • sandbox: no
  • version: nix-env (Nix) 1.11.16
  • channels(root): "nixos-17.09.3243.bca2ee28db4"
  • channels(b): "unstable-18.09pre138871.af55a0c3002"
  • nixpkgs: /nix/var/nix/profiles/per-user/root/channels/nixos/nixpkgs
@FRidh
Copy link
Member

FRidh commented May 10, 2018

#2109 related?

@chreekat
Copy link
Contributor Author

Yes, it does seem related, in that that issue was opened by someone with the opposite intuition running into the opposite behavior. Fun!

@chreekat
Copy link
Contributor Author

By the way, for this issue, hard links work fine. It's just symlinks that surprise me.

@chreekat
Copy link
Contributor Author

I've changed my tune; I'm ok with symlinks acting like portals. Closing.

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

2 participants