NixOS / nix

Nix, the purely functional package manager
https://nixos.org/
GNU Lesser General Public License v2.1
12.6k stars 1.51k forks source link

nix-prefetch-url fails to unpack files #4921

Open SuperSandro2000 opened 3 years ago

SuperSandro2000 commented 3 years ago

Describe the bug

Prefetching an archive with nix-prefetch-url --unpackis broken for me. It always happens with the same file for the same archive. /tmp has about 6GB free which should be enough to fetch nixpkgs master.

Steps To Reproduce

$ nix-prefetch-url --unpack https://github.com/NixOS/nixpkgs/archive/master.zip
error: failed to extract archive (Can't create '/tmp/nix-1307184-0/unpacked/nixpkgs-master/pkgs/development/tools/ocaml/findlib/default.nix')
unlinkat(14, "tmp", 0)                  = 0                                                                                                                       [2309/45650]close(14)                               = 0
unlinkat(7, "nix-1310781-0", AT_REMOVEDIR) = 0
close(7)                                = 0
stat("/nix/var/nix/db/db.sqlite", {st_mode=S_IFREG|0644, st_size=1744773120, ...}) = 0
fcntl(4, F_SETLK, {l_type=F_WRLCK, l_whence=SEEK_SET, l_start=1073741824, l_len=1}) = 0
fcntl(4, F_SETLK, {l_type=F_WRLCK, l_whence=SEEK_SET, l_start=1073741826, l_len=510}) = 0
unlink("/nix/var/nix/db/db.sqlite-shm") = 0
munmap(0x7cbf1fe7d000, 32768)           = 0
close(6)                                = 0
close(5)                                = 0
unlink("/nix/var/nix/db/db.sqlite-wal") = 0
fcntl(4, F_SETLK, {l_type=F_UNLCK, l_whence=SEEK_SET, l_start=1073741824, l_len=2}) = 0
fcntl(4, F_SETLK, {l_type=F_UNLCK, l_whence=SEEK_SET, l_start=0, l_len=0}) = 0
fstat(4, {st_mode=S_IFREG|0644, st_size=1744773120, ...}) = 0
stat("/nix/var/nix/db/db.sqlite", {st_mode=S_IFREG|0644, st_size=1744773120, ...}) = 0
close(4)                                = 0
close(3)                                = 0
)                  = 4
futex(0x23c0430, FUTEX_WAKE_PRIVATE, 1) = 1
futex(0x23c0308, FUTEX_WAKE_PRIVATE, 1) = 1
write(2, "\33[31;1merror:\33[0m failed to extr"..., 190error: failed to extract archive (Can't create '/tmp/nix-1310781-0/unpacked/nixpkgs-39c7783ea1e665daed769e7fa8ff3c3f0a07131f/pkgs/development/tools/ocaml/findlib')
) = 190
write(11, " ", 1)                       = 1
futex(0x7cbf1fe7c910, FUTEX_WAIT, 1310791, NULL) = 0
write(12, "\27\3\3\0\23~gf\262\224v\374i\3560\232\246\224\317\241\307>\271z", 24) = 24
close(12)                               = 0
openat(AT_FDCWD, "/proc/sys/vm/overcommit_memory", O_RDONLY|O_CLOEXEC) = 3
read(3, "1", 1)                         = 1
close(3)                                = 0
madvise(0x7cbf101c0000, 32768, MADV_DONTNEED) = 0
write(13, "\27\3\3\0\23\324\256\34\16[@\0341h\3276\214R\345\27\30^^\23", 24) = 24
close(13)                               = 0
close(8)                                = 0
close(9)                                = 0
close(11)                               = 0
close(10)                               = 0
exit_group(1)                           = ?
+++ exited with 1 +++

Expected behavior

It should return a store path like the stable nix-prefetch-url does

nix-env --version output

nix-env (Nix) 2.4pre20210601_5985b8b

Additional context

Add any other context about the problem here.


Edit:

I tested it with the nixUnstable from 21.05 and master and I think the breakage happens between these two commits: https://github.com/NixOS/nix/compare/6d2553ae1496288554e871c530836428f405fd67...5985b8b5275605ddd5e92e2f0a7a9f494ac6e35d

It works in nix-shell for some reason.


When I set TMPDIR=/run/user/1000 it works.

SuperSandro2000 commented 3 years ago

I think this error was caused because I filled up the inodes on my /tmp tmpfs

df -i /tmp
Filesystem     Type  Inodes IUsed IFree IUse% Mounted on
tmpfs          tmpfs   400K  125K  276K   32% /tmp

Better debug output or error messages would be certainly useful.

stale[bot] commented 2 years ago

I marked this as stale due to inactivity. → More info

jeff-hykin commented 1 year ago

For anyone getting this issue on Docker (e.g. future me) here are some quick commands for clearing up space:

# prune dangling volumes (basically always safe)
docker volume rm `docker volume ls -q -f dangling=true`

#
# decide each of these manually
#

# remove images not used by any container
docker rmi $(docker images -q)

# ! prune containers
docker container prune

# (VERY AGRESSIVE) remove images not being used by any ACTIVE container
docker rmi -f $(docker images -q)