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

fetchzip can produce "mv: Permission denied" errors on certain zip-files #136030

Closed
nagy opened this issue Aug 28, 2021 · 1 comment · Fixed by #137045
Closed

fetchzip can produce "mv: Permission denied" errors on certain zip-files #136030

nagy opened this issue Aug 28, 2021 · 1 comment · Fixed by #137045

Comments

@nagy
Copy link
Member

nagy commented Aug 28, 2021

Describe the bug

Currently, if you try to run this derivation

{ pkgs ? import <nixpkgs> {} }:
with pkgs;
fetchzip {
  url = "https://files.sharetextures.com/file/Share-Textures/leaf_1-4K.zip";
  sha256 = "1mjyl7pln2c0a0hpqf3sjxmmq5hf33lgcy10fjpdr2km5d0i53yf";
}

You should be seeing something like this:

building '/nix/store/fs2v9xk20dwcq4wawnibhzaqwdkwcxsl-source.drv'...

trying https://files.sharetextures.com/file/Share-Textures/leaf_1-4K.zip
  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed
100 20.8M  100 20.8M    0     0  6204k      0  0:00:03  0:00:03 --:--:-- 6204k
unpacking source archive /build/leaf_1-4K.zip
mv: cannot remove '/build/unpack/leaf_1-4K/4K-leaf_1-specular.jpg': Permission denied
mv: cannot remove '/build/unpack/leaf_1-4K/4K-leaf_1-normal.jpg': Permission denied
mv: cannot remove '/build/unpack/leaf_1-4K/4K-leaf_1-displacement.jpg': Permission denied
mv: cannot remove '/build/unpack/leaf_1-4K/4K-leaf_1-diffuse.jpg': Permission denied
mv: cannot remove '/build/unpack/leaf_1-4K/4K-leaf_1-ao.jpg': Permission denied
builder for '/nix/store/fs2v9xk20dwcq4wawnibhzaqwdkwcxsl-source.drv' failed with exit code 1
error: build of '/nix/store/fs2v9xk20dwcq4wawnibhzaqwdkwcxsl-source.drv' failed

The reason for this is that the top-level directory of this zip file does not have write permissions, therefore the mv command fails:

$ ls -lah leaf_1-4K
dr-xr-xr-x 2 user users  140 Jul  2 00:30 .

I was able to fix this with the following patch to the fetchzip function:

diff --git a/pkgs/build-support/fetchzip/default.nix b/pkgs/build-support/fetchzip/default.nix
index b174c252fc0..8e814588af2 100644
--- a/pkgs/build-support/fetchzip/default.nix
+++ b/pkgs/build-support/fetchzip/default.nix
@@ -51,6 +51,7 @@ in {
       if [ -f "$unpackDir/$fn" ]; then
         mkdir $out
       fi
+      chmod 755 "$unpackDir/$fn"
       mv "$unpackDir/$fn" "$out"
     '' else ''
       mv "$unpackDir" "$out"

To me, this seems like an idempotent change, so it should not hurt any other derivations, while it can correct some of these "unusual" zip files. What do you think? Would this be okay as a PR?

Steps To Reproduce

Steps to reproduce the behavior:

  1. place the above derivation containing fetchzip into a file.
  2. run nix-build on that file

Expected behavior

I expect the derivation to work.

Screenshots

Additional context

Notify maintainers

@SuperSandro2000 , sorry I dont know who else to ping.

Metadata

@Artturin
Copy link
Member

Artturin commented Sep 8, 2021

#137045

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

Successfully merging a pull request may close this issue.

3 participants