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

Regression: symbolic links in the build sandbox become regular files unexpectedly #10525

Closed
Atry opened this issue Apr 17, 2024 · 2 comments
Closed
Labels
bug regression Something doesn't work anymore

Comments

@Atry
Copy link
Contributor

Atry commented Apr 17, 2024

Describe the bug

When I create a derivation of a symbolic link:

hello = pkgs.runCommand "hello" { } ''
  ln -s ${pkgs.hello}/bin/hello $out
'';

then print it from another derivation:

ls-hello = pkgs.runCommand "ls-hello" { } ''
  ls -l ${hello} > $out
'';

the output path of hello becomes a regular file.

I created a simple reproduction at https://github.com/Atry/nix-regression-sandbox-symbolic-links/blob/main/flake.nix

Steps To Reproduce

  1. Start nix-daemon service 2.21.0
  2. Run nix run github:Atry/nix-regression-sandbox-symbolic-links#print-ls-hello

The output is:

++ /nix/store/cydbsmqkxk30didm1rlz8ffk5wfa9gva-nix-2.18.2/bin/nix build --no-link --print-out-paths /nix/store/jpxm4snhyx07i4gr7r2nzq4dfqm8rfy5-rhz512l9ahfz4228n11lwqqxx4a2z1hs-source#hello
+ HELLO_FILE=/nix/store/r6lqcxqvm8q574rfba804d5gsxspnrrp-hello
+ ls -l /nix/store/r6lqcxqvm8q574rfba804d5gsxspnrrp-hello
lrwxrwxrwx 2 root root 66 Jan  1  1970 /nix/store/r6lqcxqvm8q574rfba804d5gsxspnrrp-hello -> /nix/store/rnxji3jf6fb0nx2v0svdqpj9ml53gyqh-hello-2.12.1/bin/hello
++ /nix/store/cydbsmqkxk30didm1rlz8ffk5wfa9gva-nix-2.18.2/bin/nix build --no-link --print-out-paths /nix/store/jpxm4snhyx07i4gr7r2nzq4dfqm8rfy5-rhz512l9ahfz4228n11lwqqxx4a2z1hs-source#ls-hello
+ LS_HELLO='-r-xr-xr-x 2 nobody nogroup 55712 Jan  1  1970 /nix/store/r6lqcxqvm8q574rfba804d5gsxspnrrp-hello'
+ /nix/store/cydbsmqkxk30didm1rlz8ffk5wfa9gva-nix-2.18.2/bin/nix-store --query --referrers-closure /nix/store/r6lqcxqvm8q574rfba804d5gsxspnrrp-hello
+ xargs nix-store --delete
finding garbage collector roots...
deleting '/nix/store/m1q7wpyrbgpfv8qzfjyxnk3bgmncbr6l-ls-hello'
deleting '/nix/store/r6lqcxqvm8q574rfba804d5gsxspnrrp-hello'
deleting unused links...
note: currently hard linking saves 136659.87 MiB
2 store paths deleted, 0.00 MiB freed
+ echo '-r-xr-xr-x 2 nobody nogroup 55712 Jan  1  1970 /nix/store/r6lqcxqvm8q574rfba804d5gsxspnrrp-hello'
-r-xr-xr-x 2 nobody nogroup 55712 Jan  1  1970 /nix/store/r6lqcxqvm8q574rfba804d5gsxspnrrp-hello

The output is unexpected because when running ls -l /nix/store/r6lqcxqvm8q574rfba804d5gsxspnrrp-hello outside of a nix build sandbox, it is a symbolic link, while when building ls-hello, it is a regular file.

The behavior is not good. For example, the inconsistent file types of r6lqcxqvm8q574rfba804d5gsxspnrrp-hello between build time and run time makes the digest computed by nix2container at build time mismatch with the digest at run time, leading to nlewo/nix2container#127.

Expected behavior

/nix/store/r6lqcxqvm8q574rfba804d5gsxspnrrp-hello should be always a symbolic link even in a sandbox, not a regular file.

nix-env --version output

nix-env (Nix) 2.21.0

Additional context

When building ls-hello in nix-daemon 2.18.2, it sees a symbolic link as expected. Therefore, this issue is a regression.

The nix client version does not matter. I used nix client 2.18.2 with nix-daemon 2.21.0 to reproduce this bug.

Priorities

Add 👍 to issues you find important.

@Atry Atry added the bug label Apr 17, 2024
Atry added a commit to Atry/nix-ml-ops that referenced this issue Apr 17, 2024
@thufschmitt
Copy link
Member

That looks like a potential instance of #9579. Can you try with latest master to see whether the bug's still there?

@thufschmitt thufschmitt added the regression Something doesn't work anymore label Apr 18, 2024
@Atry
Copy link
Contributor Author

Atry commented Apr 24, 2024

Fixed in #10456

@Atry Atry closed this as completed Apr 24, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug regression Something doesn't work anymore
Projects
None yet
Development

No branches or pull requests

2 participants