nix-store --delete fails to delete derivations whose outputs exist #282

Open
opened 2024-05-08 06:49:36 +00:00 by jade · 10 comments
Owner

n.b. we know that there are spurious-liveness issues caused by sudo env-vars, which we probably should do something about, but this happens even without sudo doing it.

~ » nix-store --add ~/Downloads/logrotate.conf.drv
/nix/store/89j4jgilyw0wyjip1yf1ai6d2fqhm8zm-logrotate.conf.drv

[root@tail-bot ~]# nix-store --query --roots  /nix/store/bn7dq460jjf7a7zyar2l8wx66az3jdk1-logrotate.conf
[root@tail-bot ~]# nix-store --delete /nix/store/bn7dq460jjf7a7zyar2l8wx66az3jdk1-logrotate.conf
finding garbage collector roots...
0 store paths deleted, 0.00 MiB freed
error: Cannot delete path '/nix/store/bn7dq460jjf7a7zyar2l8wx66az3jdk1-logrotate.conf' since it is still alive. To find out why, use: nix-store --query --roots

Below is a hex dump of the offending file, which one can un-hexdump and then reproduce this bug with.

logrotate.conf.drv

Use xxd -r to reconstitute the file.

~ » xxd Downloads/logrotate.conf.drv
00000000: 4465 7269 7665 285b 2822 6f75 7422 2c22  Derive([("out","
00000010: 2f6e 6978 2f73 746f 7265 2f62 6e37 6471  /nix/store/bn7dq
00000020: 3436 306a 6a66 3761 377a 7961 7232 6c38  460jjf7a7zyar2l8
00000030: 7778 3636 617a 336a 646b 312d 6c6f 6772  wx66az3jdk1-logr
00000040: 6f74 6174 652e 636f 6e66 222c 2222 2c22  otate.conf","","
00000050: 2229 5d2c 5b28 222f 6e69 782f 7374 6f72  ")],[("/nix/stor
00000060: 652f 3039 7773 6871 3467 356d 6332 786a  e/09wshq4g5mc2xj
00000070: 7832 3477 6d78 6c77 3031 386c 7935 6d78  x24wmxlw018ly5mx
00000080: 676c 2d62 6173 682d 352e 322d 7031 352e  gl-bash-5.2-p15.
00000090: 6472 7622 2c5b 226f 7574 225d 292c 2822  drv",["out"]),("
000000a0: 2f6e 6978 2f73 746f 7265 2f64 6b31 6a6a  /nix/store/dk1jj
000000b0: 336c 3568 6371 3166 646b 6262 7871 6863  3l5hcq1fdkbbxqhc
000000c0: 7a71 336e 366a 7a33 3930 392d 6c6f 6772  zq3n6jz3909-logr
000000d0: 6f74 6174 652d 332e 3231 2e30 2e64 7276  otate-3.21.0.drv
000000e0: 222c 5b22 6f75 7422 5d29 2c28 222f 6e69  ",["out"]),("/ni
000000f0: 782f 7374 6f72 652f 6a36 6266 6b37 666a  x/store/j6bfk7fj
00000100: 6b6b 6137 3568 3661 7163 3064 7670 3576  kka75h6aqc0dvp5v
00000110: 7768 6d35 6161 6d6a 2d63 6f72 6575 7469  whm5aamj-coreuti
00000120: 6c73 2d39 2e33 2e64 7276 222c 5b22 6f75  ls-9.3.drv",["ou
00000130: 7422 5d29 2c28 222f 6e69 782f 7374 6f72  t"]),("/nix/stor
00000140: 652f 6d62 3968 6b39 6371 7767 7267 6c37  e/mb9hk9cqwgrgl7
00000150: 6779 6970 7970 6e32 6831 7766 7a34 3968  gyipypn2h1wfz49h
00000160: 3473 2d73 7464 656e 762d 6c69 6e75 782e  4s-stdenv-linux.
00000170: 6472 7622 2c5b 226f 7574 225d 295d 2c5b  drv",["out"])],[
00000180: 222f 6e69 782f 7374 6f72 652f 7636 7833  "/nix/store/v6x3
00000190: 6373 3339 346a 6771 6662 6930 6134 3270  cs394jgqfbi0a42p
000001a0: 616d 3730 3866 6c78 6170 6868 2d64 6566  am708flxaphh-def
000001b0: 6175 6c74 2d62 7569 6c64 6572 2e73 6822  ault-builder.sh"
000001c0: 5d2c 2278 3836 5f36 342d 6c69 6e75 7822  ],"x86_64-linux"
000001d0: 2c22 2f6e 6978 2f73 746f 7265 2f71 3163  ,"/nix/store/q1c
000001e0: 3266 6c63 796b 6772 3477 7767 3561 3668  2flcykgr4wwg5a6h
000001f0: 3435 3068 7862 6b34 6368 3538 392d 6261  450hxbk4ch589-ba
00000200: 7368 2d35 2e32 2d70 3135 2f62 696e 2f62  sh-5.2-p15/bin/b
00000210: 6173 6822 2c5b 222d 6522 2c22 2f6e 6978  ash",["-e","/nix
00000220: 2f73 746f 7265 2f76 3678 3363 7333 3934  /store/v6x3cs394
00000230: 6a67 7166 6269 3061 3432 7061 6d37 3038  jgqfbi0a42pam708
00000240: 666c 7861 7068 682d 6465 6661 756c 742d  flxaphh-default-
00000250: 6275 696c 6465 722e 7368 225d 2c5b 2822  builder.sh"],[("
00000260: 5f5f 7374 7275 6374 7572 6564 4174 7472  __structuredAttr
00000270: 7322 2c22 2229 2c28 2261 6c6c 6f77 5375  s",""),("allowSu
00000280: 6273 7469 7475 7465 7322 2c22 2229 2c28  bstitutes",""),(
00000290: 2262 7569 6c64 436f 6d6d 616e 6422 2c22  "buildCommand","
000002a0: 7461 7267 6574 3d24 6f75 7427 275c 6e6d  target=$out''\nm
000002b0: 6b64 6972 202d 7020 5c22 2428 6469 726e  kdir -p \"$(dirn
000002c0: 616d 6520 5c22 2474 6172 6765 745c 2229  ame \"$target\")
000002d0: 5c22 5c6e 5c6e 6966 205b 202d 6520 5c22  \"\n\nif [ -e \"
000002e0: 2474 6578 7450 6174 685c 2220 5d3b 2074  $textPath\" ]; t
000002f0: 6865 6e5c 6e20 206d 7620 5c22 2474 6578  hen\n  mv \"$tex
00000300: 7450 6174 685c 2220 5c22 2474 6172 6765  tPath\" \"$targe
00000310: 745c 225c 6e65 6c73 655c 6e20 2065 6368  t\"\nelse\n  ech
00000320: 6f20 2d6e 205c 2224 7465 7874 5c22 203e  o -n \"$text\" >
00000330: 205c 2224 7461 7267 6574 5c22 5c6e 6669   \"$target\"\nfi
00000340: 5c6e 5c6e 6966 205b 202d 6e20 5c22 2465  \n\nif [ -n \"$e
00000350: 7865 6375 7461 626c 655c 2220 5d3b 2074  xecutable\" ]; t
00000360: 6865 6e5c 6e20 2063 686d 6f64 202b 7820  hen\n  chmod +x 
00000370: 5c22 2474 6172 6765 745c 225c 6e66 695c  \"$target\"\nfi\
00000380: 6e5c 6e65 7661 6c20 5c22 2463 6865 636b  n\neval \"$check
00000390: 5068 6173 655c 225c 6e22 292c 2822 6275  Phase\"\n"),("bu
000003a0: 696c 6449 6e70 7574 7322 2c22 2229 2c28  ildInputs",""),(
000003b0: 2262 7569 6c64 6572 222c 222f 6e69 782f  "builder","/nix/
000003c0: 7374 6f72 652f 7131 6332 666c 6379 6b67  store/q1c2flcykg
000003d0: 7234 7777 6735 6136 6834 3530 6878 626b  r4wwg5a6h450hxbk
000003e0: 3463 6835 3839 2d62 6173 682d 352e 322d  4ch589-bash-5.2-
000003f0: 7031 352f 6269 6e2f 6261 7368 2229 2c28  p15/bin/bash"),(
00000400: 2263 6865 636b 5068 6173 6522 2c22 2320  "checkPhase","# 
00000410: 6c6f 6772 6f74 6174 6520 2d2d 6465 6275  logrotate --debu
00000420: 6720 616c 736f 2063 6865 636b 7320 7468  g also checks th
00000430: 6174 2075 7365 7273 2073 7065 6369 6669  at users specifi
00000440: 6564 2069 6e20 636f 6e66 6967 5c6e 2320  ed in config\n# 
00000450: 6669 6c65 2065 7869 7374 2c20 6275 7420  file exist, but 
00000460: 7765 206f 6e6c 7920 6861 7665 2073 616e  we only have san
00000470: 6462 6f78 6564 2075 7365 7273 2068 6572  dboxed users her
00000480: 6520 736f 2062 726f 776e 2074 6865 7365  e so brown these
00000490: 5c6e 2320 6f75 742e 2061 6363 6f72 6469  \n# out. accordi
000004a0: 6e67 2074 6f20 6d61 6e20 7061 6765 2074  ng to man page t
000004b0: 6861 7420 6d65 616e 7320 7375 2c20 6372  hat means su, cr
000004c0: 6561 7465 2061 6e64 2063 7265 6174 656f  eate and createo
000004d0: 6c64 6469 722e 5c6e 2320 6669 6c65 7320  lddir.\n# files 
000004e0: 7265 7175 6972 6564 2074 6f20 6578 6973  required to exis
000004f0: 7420 616c 736f 2077 6f6e 2774 2062 6520  t also won't be 
00000500: 7072 6573 656e 742c 2073 6f20 6d69 7373  present, so miss
00000510: 696e 676f 6b20 6973 2066 6f72 6365 642e  ingok is forced.
00000520: 5c6e 6563 686f 2049 414b 5c6e 6361 7420  \necho IAK\ncat 
00000530: 2f65 7463 2f67 726f 7570 5c6e 6964 202d  /etc/group\nid -
00000540: 675c 6e75 7365 723d 2428 2f6e 6978 2f73  g\nuser=$(/nix/s
00000550: 746f 7265 2f62 626c 796a 3562 3369 6938  tore/bblyj5b3ii8
00000560: 6e36 7634 7261 306e 6233 3763 6d69 336c  n6v4ra0nb37cmi3l
00000570: 6638 727a 392d 636f 7265 7574 696c 732d  f8rz9-coreutils-
00000580: 392e 332f 6269 6e2f 6964 202d 756e 295c  9.3/bin/id -un)\
00000590: 6e67 726f 7570 3d24 282f 6e69 782f 7374  ngroup=$(/nix/st
000005a0: 6f72 652f 6262 6c79 6a35 6233 6969 386e  ore/bblyj5b3ii8n
000005b0: 3676 3472 6130 6e62 3337 636d 6933 6c66  6v4ra0nb37cmi3lf
000005c0: 3872 7a39 2d63 6f72 6575 7469 6c73 2d39  8rz9-coreutils-9
000005d0: 2e33 2f62 696e 2f69 6420 2d67 6e29 5c6e  .3/bin/id -gn)\n
000005e0: 7365 6420 2d65 205c 2273 2f5c 5c62 7375  sed -e \"s/\\bsu
000005f0: 5c5c 732e 2a2f 7375 2024 7573 6572 2024  \\s.*/su $user $
00000600: 6772 6f75 702f 5c22 205c 5c5c 6e20 2020  group/\" \\\n   
00000610: 202d 6520 5c22 732f 5c5c 625c 5c28 6372   -e \"s/\\b\\(cr
00000620: 6561 7465 5c5c 735c 5c2b 5b30 2d39 5d2a  eate\\s\\+[0-9]*
00000630: 5c5c 732a 5c5c 7c63 7265 6174 656f 6c64  \\s*\\|createold
00000640: 6469 725c 5c73 5c5c 2b5b 302d 395d 2a5c  dir\\s\\+[0-9]*\
00000650: 5c73 5c5c 2b5c 5c29 2e2a 2f5c 5c31 2475  \s\\+\\).*/\\1$u
00000660: 7365 7220 2467 726f 7570 2f5c 2220 5c5c  ser $group/\" \\
00000670: 5c6e 2020 2020 2d65 205c 2231 696d 6973  \n    -e \"1imis
00000680: 7369 6e67 6f6b 5c22 202d 6520 5c22 732f  singok\" -e \"s/
00000690: 5c5c 626e 6f6d 6973 7369 6e67 6f6b 5c5c  \\bnomissingok\\
000006a0: 622f 2f5c 2220 5c5c 5c6e 2020 2020 246f  b//\" \\\n    $o
000006b0: 7574 203e 206c 6f67 726f 7461 7465 2e63  ut > logrotate.c
000006c0: 6f6e 665c 6e23 2053 696e 6365 2074 6869  onf\n# Since thi
000006d0: 7320 6d61 6b65 7320 666f 7220 7665 7279  s makes for very
000006e0: 2076 6572 626f 7365 2062 7569 6c64 7320   verbose builds 
000006f0: 6f6e 6c79 2073 686f 7720 7265 616c 2065  only show real e
00000700: 7272 6f72 2e5c 6e23 2054 6865 7265 2069  rror.\n# There i
00000710: 7320 6e6f 2077 6179 2074 6f20 636f 6e74  s no way to cont
00000720: 726f 6c20 6c6f 6720 6c65 7665 6c2c 2062  rol log level, b
00000730: 7574 206c 6f67 726f 7461 7465 2068 6172  ut logrotate har
00000740: 6463 6f64 6573 5c6e 2320 2765 7272 6f72  dcodes\n# 'error
00000750: 3a27 2061 7420 636f 6d6d 6f6e 206c 6f67  :' at common log
00000760: 206c 6576 656c 2c20 736f 2077 6520 6361   level, so we ca
00000770: 6e20 7573 6520 6772 6570 2c20 7461 6b69  n use grep, taki
00000780: 6e67 2063 6172 655c 6e23 2074 6f20 6b65  ng care\n# to ke
00000790: 6570 2065 7272 6f72 2063 6f64 6573 5c6e  ep error codes\n
000007a0: 7365 7420 2d6f 2070 6970 6566 6169 6c5c  set -o pipefail\
000007b0: 6e69 6620 2120 2f6e 6978 2f73 746f 7265  nif ! /nix/store
000007c0: 2f6d 396d 7366 6e35 3764 676c 7668 3878  /m9msfn57dglvh8x
000007d0: 7a6d 7a62 636b 6466 6335 6330 696a 616e  zmzbckdfc5c0ijan
000007e0: 632d 6c6f 6772 6f74 6174 652d 332e 3231  c-logrotate-3.21
000007f0: 2e30 2f73 6269 6e2f 6c6f 6772 6f74 6174  .0/sbin/logrotat
00000800: 6520 2d73 206c 6f67 726f 7461 7465 2e73  e -s logrotate.s
00000810: 7461 7475 7320 5c5c 5c6e 2020 2020 2020  tatus \\\n      
00000820: 2020 2020 2020 2020 2020 2d2d 6465 6275            --debu
00000830: 6720 6c6f 6772 6f74 6174 652e 636f 6e66  g logrotate.conf
00000840: 2032 3e26 3120 5c5c 5c6e 2020 2020 2020   2>&1 \\\n      
00000850: 2020 2020 2020 7c20 2820 2120 6772 6570        | ( ! grep
00000860: 205c 2265 7272 6f72 3a5c 2220 2920 3e20   \"error:\" ) > 
00000870: 6c6f 6772 6f74 6174 652d 6572 726f 723b  logrotate-error;
00000880: 2074 6865 6e5c 6e20 2020 2020 2020 2065   then\n        e
00000890: 6368 6f20 5c22 4c6f 6772 6f74 6174 6520  cho \"Logrotate 
000008a0: 636f 6e66 6967 7572 6174 696f 6e20 6368  configuration ch
000008b0: 6563 6b20 6661 696c 6564 2e5c 225c 6e20  eck failed.\"\n 
000008c0: 2020 2020 2020 2065 6368 6f20 5c22 5468         echo \"Th
000008d0: 6520 6661 696c 696e 6720 636f 6e66 6967  e failing config
000008e0: 7572 6174 696f 6e20 2861 6674 6572 2061  uration (after a
000008f0: 646a 7573 746d 656e 7473 2074 6f20 7061  djustments to pa
00000900: 7373 2074 6573 7473 2069 6e20 7361 6e64  ss tests in sand
00000910: 626f 7829 2077 6173 3a5c 225c 6e20 2020  box) was:\"\n   
00000920: 2020 2020 2070 7269 6e74 6620 5c22 2573       printf \"%s
00000930: 5c5c 6e5c 2220 5c22 2d2d 2d2d 2d2d 2d5c  \\n\" \"-------\
00000940: 225c 6e20 2020 2020 2020 2063 6174 206c  "\n        cat l
00000950: 6f67 726f 7461 7465 2e63 6f6e 665c 6e20  ogrotate.conf\n 
00000960: 2020 2020 2020 2070 7269 6e74 6620 5c22         printf \"
00000970: 2573 5c5c 6e5c 2220 5c22 2d2d 2d2d 2d2d  %s\\n\" \"------
00000980: 2d5c 225c 6e20 2020 2020 2020 2065 6368  -\"\n        ech
00000990: 6f20 5c22 5468 6520 6572 726f 7220 7265  o \"The error re
000009a0: 706f 7274 6564 2062 7920 6c6f 6772 6f74  ported by logrot
000009b0: 6174 6520 7761 7320 6173 2066 6f6c 6c6f  ate was as follo
000009c0: 773a 5c22 5c6e 2020 2020 2020 2020 7072  w:\"\n        pr
000009d0: 696e 7466 205c 2225 735c 5c6e 5c22 205c  intf \"%s\\n\" \
000009e0: 222d 2d2d 2d2d 2d2d 5c22 5c6e 2020 2020  "-------\"\n    
000009f0: 2020 2020 6361 7420 6c6f 6772 6f74 6174      cat logrotat
00000a00: 652d 6572 726f 725c 6e20 2020 2020 2020  e-error\n       
00000a10: 2070 7269 6e74 6620 5c22 2573 5c5c 6e5c   printf \"%s\\n\
00000a20: 2220 5c22 2d2d 2d2d 2d2d 2d5c 225c 6e20  " \"-------\"\n 
00000a30: 2020 2020 2020 2065 6368 6f20 5c22 596f         echo \"Yo
00000a40: 7520 6361 6e20 6469 7361 626c 6520 7468  u can disable th
00000a50: 6973 2063 6865 636b 2077 6974 6820 7365  is check with se
00000a60: 7276 6963 6573 2e6c 6f67 726f 7461 7465  rvices.logrotate
00000a70: 2e63 6865 636b 436f 6e66 6967 203d 2066  .checkConfig = f
00000a80: 616c 7365 2c5c 225c 6e20 2020 2020 2020  alse,\"\n       
00000a90: 2065 6368 6f20 5c22 6275 7420 6966 2079   echo \"but if y
00000aa0: 6f75 2074 6869 6e6b 2069 7420 7368 6f75  ou think it shou
00000ab0: 6c64 2077 6f72 6b20 706c 6561 7365 2072  ld work please r
00000ac0: 6570 6f72 7420 7468 6973 2066 6169 6c75  eport this failu
00000ad0: 7265 2061 6c6f 6e67 2077 6974 685c 225c  re along with\"\
00000ae0: 6e20 2020 2020 2020 2065 6368 6f20 5c22  n        echo \"
00000af0: 7468 6520 636f 6e66 6967 2066 696c 6520  the config file 
00000b00: 6265 696e 6720 7465 7374 6564 215c 225c  being tested!\"\
00000b10: 6e20 2020 2020 2020 2066 616c 7365 5c6e  n        false\n
00000b20: 6669 5c6e 2229 2c28 2263 6d61 6b65 466c  fi\n"),("cmakeFl
00000b30: 6167 7322 2c22 2229 2c28 2263 6f6e 6669  ags",""),("confi
00000b40: 6775 7265 466c 6167 7322 2c22 2229 2c28  gureFlags",""),(
00000b50: 2264 6570 7342 7569 6c64 4275 696c 6422  "depsBuildBuild"
00000b60: 2c22 2229 2c28 2264 6570 7342 7569 6c64  ,""),("depsBuild
00000b70: 4275 696c 6450 726f 7061 6761 7465 6422  BuildPropagated"
00000b80: 2c22 2229 2c28 2264 6570 7342 7569 6c64  ,""),("depsBuild
00000b90: 5461 7267 6574 222c 2222 292c 2822 6465  Target",""),("de
00000ba0: 7073 4275 696c 6454 6172 6765 7450 726f  psBuildTargetPro
00000bb0: 7061 6761 7465 6422 2c22 2229 2c28 2264  pagated",""),("d
00000bc0: 6570 7348 6f73 7448 6f73 7422 2c22 2229  epsHostHost","")
00000bd0: 2c28 2264 6570 7348 6f73 7448 6f73 7450  ,("depsHostHostP
00000be0: 726f 7061 6761 7465 6422 2c22 2229 2c28  ropagated",""),(
00000bf0: 2264 6570 7354 6172 6765 7454 6172 6765  "depsTargetTarge
00000c00: 7422 2c22 2229 2c28 2264 6570 7354 6172  t",""),("depsTar
00000c10: 6765 7454 6172 6765 7450 726f 7061 6761  getTargetPropaga
00000c20: 7465 6422 2c22 2229 2c28 2264 6f43 6865  ted",""),("doChe
00000c30: 636b 222c 2222 292c 2822 646f 496e 7374  ck",""),("doInst
00000c40: 616c 6c43 6865 636b 222c 2222 292c 2822  allCheck",""),("
00000c50: 656e 6162 6c65 5061 7261 6c6c 656c 4275  enableParallelBu
00000c60: 696c 6469 6e67 222c 2231 2229 2c28 2265  ilding","1"),("e
00000c70: 6e61 626c 6550 6172 616c 6c65 6c43 6865  nableParallelChe
00000c80: 636b 696e 6722 2c22 3122 292c 2822 656e  cking","1"),("en
00000c90: 6162 6c65 5061 7261 6c6c 656c 496e 7374  ableParallelInst
00000ca0: 616c 6c69 6e67 222c 2231 2229 2c28 2265  alling","1"),("e
00000cb0: 7865 6375 7461 626c 6522 2c22 2229 2c28  xecutable",""),(
00000cc0: 226d 6573 6f6e 466c 6167 7322 2c22 2229  "mesonFlags","")
00000cd0: 2c28 226e 616d 6522 2c22 6c6f 6772 6f74  ,("name","logrot
00000ce0: 6174 652e 636f 6e66 2229 2c28 226e 6174  ate.conf"),("nat
00000cf0: 6976 6542 7569 6c64 496e 7075 7473 222c  iveBuildInputs",
00000d00: 2222 292c 2822 6f75 7422 2c22 2f6e 6978  ""),("out","/nix
00000d10: 2f73 746f 7265 2f62 6e37 6471 3436 306a  /store/bn7dq460j
00000d20: 6a66 3761 377a 7961 7232 6c38 7778 3636  jf7a7zyar2l8wx66
00000d30: 617a 336a 646b 312d 6c6f 6772 6f74 6174  az3jdk1-logrotat
00000d40: 652e 636f 6e66 2229 2c28 226f 7574 7075  e.conf"),("outpu
00000d50: 7473 222c 226f 7574 2229 2c28 2270 6173  ts","out"),("pas
00000d60: 7341 7346 696c 6522 2c22 6275 696c 6443  sAsFile","buildC
00000d70: 6f6d 6d61 6e64 2074 6578 7422 292c 2822  ommand text"),("
00000d80: 7061 7463 6865 7322 2c22 2229 2c28 2270  patches",""),("p
00000d90: 7265 6665 724c 6f63 616c 4275 696c 6422  referLocalBuild"
00000da0: 2c22 3122 292c 2822 7072 6f70 6167 6174  ,"1"),("propagat
00000db0: 6564 4275 696c 6449 6e70 7574 7322 2c22  edBuildInputs","
00000dc0: 2229 2c28 2270 726f 7061 6761 7465 644e  "),("propagatedN
00000dd0: 6174 6976 6542 7569 6c64 496e 7075 7473  ativeBuildInputs
00000de0: 222c 2222 292c 2822 7374 6465 6e76 222c  ",""),("stdenv",
00000df0: 222f 6e69 782f 7374 6f72 652f 7070 7935  "/nix/store/ppy5
00000e00: 676d 3672 3637 3663 6864 6135 6967 3578  gm6r676chda5ig5x
00000e10: 6762 6872 3873 6233 7266 6170 2d73 7464  gbhr8sb3rfap-std
00000e20: 656e 762d 6c69 6e75 7822 292c 2822 7374  env-linux"),("st
00000e30: 7269 6374 4465 7073 222c 2222 292c 2822  rictDeps",""),("
00000e40: 7379 7374 656d 222c 2278 3836 5f36 342d  system","x86_64-
00000e50: 6c69 6e75 7822 292c 2822 7465 7874 222c  linux"),("text",
00000e60: 2277 6565 6b6c 795c 6e6d 6973 7369 6e67  "weekly\nmissing
00000e70: 6f6b 5c6e 6e6f 7469 6665 6d70 7479 5c6e  ok\nnotifempty\n
00000e80: 726f 7461 7465 2034 5c6e 5c6e 5c22 2f76  rotate 4\n\n\"/v
00000e90: 6172 2f6c 6f67 2f62 746d 705c 2220 7b5c  ar/log/btmp\" {\
00000ea0: 6e20 2063 7265 6174 6520 3036 3630 2072  n  create 0660 r
00000eb0: 6f6f 7420 7574 6d70 5c6e 2020 6d6f 6e74  oot utmp\n  mont
00000ec0: 686c 795c 6e20 206d 696e 7369 7a65 2031  hly\n  minsize 1
00000ed0: 4d5c 6e20 2072 6f74 6174 6520 315c 6e7d  M\n  rotate 1\n}
00000ee0: 5c6e 5c6e 5c22 2f76 6172 2f6c 6f67 2f77  \n\n\"/var/log/w
00000ef0: 746d 705c 2220 7b5c 6e20 2063 7265 6174  tmp\" {\n  creat
00000f00: 6520 3036 3634 2072 6f6f 7420 7574 6d70  e 0664 root utmp
00000f10: 5c6e 2020 6d6f 6e74 686c 795c 6e20 206d  \n  monthly\n  m
00000f20: 696e 7369 7a65 2031 4d5c 6e20 2072 6f74  insize 1M\n  rot
00000f30: 6174 6520 315c 6e7d 5c6e 2229 5d29       ate 1\n}\n")])
nix --version
nix (Lix, like Nix) 2.90.0-lixpre20240506-f75d075
n.b. we know that there are spurious-liveness issues caused by sudo env-vars, which we probably should do something about, but this happens even without sudo doing it. ``` ~ » nix-store --add ~/Downloads/logrotate.conf.drv /nix/store/89j4jgilyw0wyjip1yf1ai6d2fqhm8zm-logrotate.conf.drv [root@tail-bot ~]# nix-store --query --roots /nix/store/bn7dq460jjf7a7zyar2l8wx66az3jdk1-logrotate.conf [root@tail-bot ~]# nix-store --delete /nix/store/bn7dq460jjf7a7zyar2l8wx66az3jdk1-logrotate.conf finding garbage collector roots... 0 store paths deleted, 0.00 MiB freed error: Cannot delete path '/nix/store/bn7dq460jjf7a7zyar2l8wx66az3jdk1-logrotate.conf' since it is still alive. To find out why, use: nix-store --query --roots ``` Below is a hex dump of the offending file, which one can un-hexdump and then reproduce this bug with. <details> <summary>logrotate.conf.drv</summary> Use `xxd -r` to reconstitute the file. ``` ~ » xxd Downloads/logrotate.conf.drv 00000000: 4465 7269 7665 285b 2822 6f75 7422 2c22 Derive([("out"," 00000010: 2f6e 6978 2f73 746f 7265 2f62 6e37 6471 /nix/store/bn7dq 00000020: 3436 306a 6a66 3761 377a 7961 7232 6c38 460jjf7a7zyar2l8 00000030: 7778 3636 617a 336a 646b 312d 6c6f 6772 wx66az3jdk1-logr 00000040: 6f74 6174 652e 636f 6e66 222c 2222 2c22 otate.conf",""," 00000050: 2229 5d2c 5b28 222f 6e69 782f 7374 6f72 ")],[("/nix/stor 00000060: 652f 3039 7773 6871 3467 356d 6332 786a e/09wshq4g5mc2xj 00000070: 7832 3477 6d78 6c77 3031 386c 7935 6d78 x24wmxlw018ly5mx 00000080: 676c 2d62 6173 682d 352e 322d 7031 352e gl-bash-5.2-p15. 00000090: 6472 7622 2c5b 226f 7574 225d 292c 2822 drv",["out"]),(" 000000a0: 2f6e 6978 2f73 746f 7265 2f64 6b31 6a6a /nix/store/dk1jj 000000b0: 336c 3568 6371 3166 646b 6262 7871 6863 3l5hcq1fdkbbxqhc 000000c0: 7a71 336e 366a 7a33 3930 392d 6c6f 6772 zq3n6jz3909-logr 000000d0: 6f74 6174 652d 332e 3231 2e30 2e64 7276 otate-3.21.0.drv 000000e0: 222c 5b22 6f75 7422 5d29 2c28 222f 6e69 ",["out"]),("/ni 000000f0: 782f 7374 6f72 652f 6a36 6266 6b37 666a x/store/j6bfk7fj 00000100: 6b6b 6137 3568 3661 7163 3064 7670 3576 kka75h6aqc0dvp5v 00000110: 7768 6d35 6161 6d6a 2d63 6f72 6575 7469 whm5aamj-coreuti 00000120: 6c73 2d39 2e33 2e64 7276 222c 5b22 6f75 ls-9.3.drv",["ou 00000130: 7422 5d29 2c28 222f 6e69 782f 7374 6f72 t"]),("/nix/stor 00000140: 652f 6d62 3968 6b39 6371 7767 7267 6c37 e/mb9hk9cqwgrgl7 00000150: 6779 6970 7970 6e32 6831 7766 7a34 3968 gyipypn2h1wfz49h 00000160: 3473 2d73 7464 656e 762d 6c69 6e75 782e 4s-stdenv-linux. 00000170: 6472 7622 2c5b 226f 7574 225d 295d 2c5b drv",["out"])],[ 00000180: 222f 6e69 782f 7374 6f72 652f 7636 7833 "/nix/store/v6x3 00000190: 6373 3339 346a 6771 6662 6930 6134 3270 cs394jgqfbi0a42p 000001a0: 616d 3730 3866 6c78 6170 6868 2d64 6566 am708flxaphh-def 000001b0: 6175 6c74 2d62 7569 6c64 6572 2e73 6822 ault-builder.sh" 000001c0: 5d2c 2278 3836 5f36 342d 6c69 6e75 7822 ],"x86_64-linux" 000001d0: 2c22 2f6e 6978 2f73 746f 7265 2f71 3163 ,"/nix/store/q1c 000001e0: 3266 6c63 796b 6772 3477 7767 3561 3668 2flcykgr4wwg5a6h 000001f0: 3435 3068 7862 6b34 6368 3538 392d 6261 450hxbk4ch589-ba 00000200: 7368 2d35 2e32 2d70 3135 2f62 696e 2f62 sh-5.2-p15/bin/b 00000210: 6173 6822 2c5b 222d 6522 2c22 2f6e 6978 ash",["-e","/nix 00000220: 2f73 746f 7265 2f76 3678 3363 7333 3934 /store/v6x3cs394 00000230: 6a67 7166 6269 3061 3432 7061 6d37 3038 jgqfbi0a42pam708 00000240: 666c 7861 7068 682d 6465 6661 756c 742d flxaphh-default- 00000250: 6275 696c 6465 722e 7368 225d 2c5b 2822 builder.sh"],[(" 00000260: 5f5f 7374 7275 6374 7572 6564 4174 7472 __structuredAttr 00000270: 7322 2c22 2229 2c28 2261 6c6c 6f77 5375 s",""),("allowSu 00000280: 6273 7469 7475 7465 7322 2c22 2229 2c28 bstitutes",""),( 00000290: 2262 7569 6c64 436f 6d6d 616e 6422 2c22 "buildCommand"," 000002a0: 7461 7267 6574 3d24 6f75 7427 275c 6e6d target=$out''\nm 000002b0: 6b64 6972 202d 7020 5c22 2428 6469 726e kdir -p \"$(dirn 000002c0: 616d 6520 5c22 2474 6172 6765 745c 2229 ame \"$target\") 000002d0: 5c22 5c6e 5c6e 6966 205b 202d 6520 5c22 \"\n\nif [ -e \" 000002e0: 2474 6578 7450 6174 685c 2220 5d3b 2074 $textPath\" ]; t 000002f0: 6865 6e5c 6e20 206d 7620 5c22 2474 6578 hen\n mv \"$tex 00000300: 7450 6174 685c 2220 5c22 2474 6172 6765 tPath\" \"$targe 00000310: 745c 225c 6e65 6c73 655c 6e20 2065 6368 t\"\nelse\n ech 00000320: 6f20 2d6e 205c 2224 7465 7874 5c22 203e o -n \"$text\" > 00000330: 205c 2224 7461 7267 6574 5c22 5c6e 6669 \"$target\"\nfi 00000340: 5c6e 5c6e 6966 205b 202d 6e20 5c22 2465 \n\nif [ -n \"$e 00000350: 7865 6375 7461 626c 655c 2220 5d3b 2074 xecutable\" ]; t 00000360: 6865 6e5c 6e20 2063 686d 6f64 202b 7820 hen\n chmod +x 00000370: 5c22 2474 6172 6765 745c 225c 6e66 695c \"$target\"\nfi\ 00000380: 6e5c 6e65 7661 6c20 5c22 2463 6865 636b n\neval \"$check 00000390: 5068 6173 655c 225c 6e22 292c 2822 6275 Phase\"\n"),("bu 000003a0: 696c 6449 6e70 7574 7322 2c22 2229 2c28 ildInputs",""),( 000003b0: 2262 7569 6c64 6572 222c 222f 6e69 782f "builder","/nix/ 000003c0: 7374 6f72 652f 7131 6332 666c 6379 6b67 store/q1c2flcykg 000003d0: 7234 7777 6735 6136 6834 3530 6878 626b r4wwg5a6h450hxbk 000003e0: 3463 6835 3839 2d62 6173 682d 352e 322d 4ch589-bash-5.2- 000003f0: 7031 352f 6269 6e2f 6261 7368 2229 2c28 p15/bin/bash"),( 00000400: 2263 6865 636b 5068 6173 6522 2c22 2320 "checkPhase","# 00000410: 6c6f 6772 6f74 6174 6520 2d2d 6465 6275 logrotate --debu 00000420: 6720 616c 736f 2063 6865 636b 7320 7468 g also checks th 00000430: 6174 2075 7365 7273 2073 7065 6369 6669 at users specifi 00000440: 6564 2069 6e20 636f 6e66 6967 5c6e 2320 ed in config\n# 00000450: 6669 6c65 2065 7869 7374 2c20 6275 7420 file exist, but 00000460: 7765 206f 6e6c 7920 6861 7665 2073 616e we only have san 00000470: 6462 6f78 6564 2075 7365 7273 2068 6572 dboxed users her 00000480: 6520 736f 2062 726f 776e 2074 6865 7365 e so brown these 00000490: 5c6e 2320 6f75 742e 2061 6363 6f72 6469 \n# out. accordi 000004a0: 6e67 2074 6f20 6d61 6e20 7061 6765 2074 ng to man page t 000004b0: 6861 7420 6d65 616e 7320 7375 2c20 6372 hat means su, cr 000004c0: 6561 7465 2061 6e64 2063 7265 6174 656f eate and createo 000004d0: 6c64 6469 722e 5c6e 2320 6669 6c65 7320 lddir.\n# files 000004e0: 7265 7175 6972 6564 2074 6f20 6578 6973 required to exis 000004f0: 7420 616c 736f 2077 6f6e 2774 2062 6520 t also won't be 00000500: 7072 6573 656e 742c 2073 6f20 6d69 7373 present, so miss 00000510: 696e 676f 6b20 6973 2066 6f72 6365 642e ingok is forced. 00000520: 5c6e 6563 686f 2049 414b 5c6e 6361 7420 \necho IAK\ncat 00000530: 2f65 7463 2f67 726f 7570 5c6e 6964 202d /etc/group\nid - 00000540: 675c 6e75 7365 723d 2428 2f6e 6978 2f73 g\nuser=$(/nix/s 00000550: 746f 7265 2f62 626c 796a 3562 3369 6938 tore/bblyj5b3ii8 00000560: 6e36 7634 7261 306e 6233 3763 6d69 336c n6v4ra0nb37cmi3l 00000570: 6638 727a 392d 636f 7265 7574 696c 732d f8rz9-coreutils- 00000580: 392e 332f 6269 6e2f 6964 202d 756e 295c 9.3/bin/id -un)\ 00000590: 6e67 726f 7570 3d24 282f 6e69 782f 7374 ngroup=$(/nix/st 000005a0: 6f72 652f 6262 6c79 6a35 6233 6969 386e ore/bblyj5b3ii8n 000005b0: 3676 3472 6130 6e62 3337 636d 6933 6c66 6v4ra0nb37cmi3lf 000005c0: 3872 7a39 2d63 6f72 6575 7469 6c73 2d39 8rz9-coreutils-9 000005d0: 2e33 2f62 696e 2f69 6420 2d67 6e29 5c6e .3/bin/id -gn)\n 000005e0: 7365 6420 2d65 205c 2273 2f5c 5c62 7375 sed -e \"s/\\bsu 000005f0: 5c5c 732e 2a2f 7375 2024 7573 6572 2024 \\s.*/su $user $ 00000600: 6772 6f75 702f 5c22 205c 5c5c 6e20 2020 group/\" \\\n 00000610: 202d 6520 5c22 732f 5c5c 625c 5c28 6372 -e \"s/\\b\\(cr 00000620: 6561 7465 5c5c 735c 5c2b 5b30 2d39 5d2a eate\\s\\+[0-9]* 00000630: 5c5c 732a 5c5c 7c63 7265 6174 656f 6c64 \\s*\\|createold 00000640: 6469 725c 5c73 5c5c 2b5b 302d 395d 2a5c dir\\s\\+[0-9]*\ 00000650: 5c73 5c5c 2b5c 5c29 2e2a 2f5c 5c31 2475 \s\\+\\).*/\\1$u 00000660: 7365 7220 2467 726f 7570 2f5c 2220 5c5c ser $group/\" \\ 00000670: 5c6e 2020 2020 2d65 205c 2231 696d 6973 \n -e \"1imis 00000680: 7369 6e67 6f6b 5c22 202d 6520 5c22 732f singok\" -e \"s/ 00000690: 5c5c 626e 6f6d 6973 7369 6e67 6f6b 5c5c \\bnomissingok\\ 000006a0: 622f 2f5c 2220 5c5c 5c6e 2020 2020 246f b//\" \\\n $o 000006b0: 7574 203e 206c 6f67 726f 7461 7465 2e63 ut > logrotate.c 000006c0: 6f6e 665c 6e23 2053 696e 6365 2074 6869 onf\n# Since thi 000006d0: 7320 6d61 6b65 7320 666f 7220 7665 7279 s makes for very 000006e0: 2076 6572 626f 7365 2062 7569 6c64 7320 verbose builds 000006f0: 6f6e 6c79 2073 686f 7720 7265 616c 2065 only show real e 00000700: 7272 6f72 2e5c 6e23 2054 6865 7265 2069 rror.\n# There i 00000710: 7320 6e6f 2077 6179 2074 6f20 636f 6e74 s no way to cont 00000720: 726f 6c20 6c6f 6720 6c65 7665 6c2c 2062 rol log level, b 00000730: 7574 206c 6f67 726f 7461 7465 2068 6172 ut logrotate har 00000740: 6463 6f64 6573 5c6e 2320 2765 7272 6f72 dcodes\n# 'error 00000750: 3a27 2061 7420 636f 6d6d 6f6e 206c 6f67 :' at common log 00000760: 206c 6576 656c 2c20 736f 2077 6520 6361 level, so we ca 00000770: 6e20 7573 6520 6772 6570 2c20 7461 6b69 n use grep, taki 00000780: 6e67 2063 6172 655c 6e23 2074 6f20 6b65 ng care\n# to ke 00000790: 6570 2065 7272 6f72 2063 6f64 6573 5c6e ep error codes\n 000007a0: 7365 7420 2d6f 2070 6970 6566 6169 6c5c set -o pipefail\ 000007b0: 6e69 6620 2120 2f6e 6978 2f73 746f 7265 nif ! /nix/store 000007c0: 2f6d 396d 7366 6e35 3764 676c 7668 3878 /m9msfn57dglvh8x 000007d0: 7a6d 7a62 636b 6466 6335 6330 696a 616e zmzbckdfc5c0ijan 000007e0: 632d 6c6f 6772 6f74 6174 652d 332e 3231 c-logrotate-3.21 000007f0: 2e30 2f73 6269 6e2f 6c6f 6772 6f74 6174 .0/sbin/logrotat 00000800: 6520 2d73 206c 6f67 726f 7461 7465 2e73 e -s logrotate.s 00000810: 7461 7475 7320 5c5c 5c6e 2020 2020 2020 tatus \\\n 00000820: 2020 2020 2020 2020 2020 2d2d 6465 6275 --debu 00000830: 6720 6c6f 6772 6f74 6174 652e 636f 6e66 g logrotate.conf 00000840: 2032 3e26 3120 5c5c 5c6e 2020 2020 2020 2>&1 \\\n 00000850: 2020 2020 2020 7c20 2820 2120 6772 6570 | ( ! grep 00000860: 205c 2265 7272 6f72 3a5c 2220 2920 3e20 \"error:\" ) > 00000870: 6c6f 6772 6f74 6174 652d 6572 726f 723b logrotate-error; 00000880: 2074 6865 6e5c 6e20 2020 2020 2020 2065 then\n e 00000890: 6368 6f20 5c22 4c6f 6772 6f74 6174 6520 cho \"Logrotate 000008a0: 636f 6e66 6967 7572 6174 696f 6e20 6368 configuration ch 000008b0: 6563 6b20 6661 696c 6564 2e5c 225c 6e20 eck failed.\"\n 000008c0: 2020 2020 2020 2065 6368 6f20 5c22 5468 echo \"Th 000008d0: 6520 6661 696c 696e 6720 636f 6e66 6967 e failing config 000008e0: 7572 6174 696f 6e20 2861 6674 6572 2061 uration (after a 000008f0: 646a 7573 746d 656e 7473 2074 6f20 7061 djustments to pa 00000900: 7373 2074 6573 7473 2069 6e20 7361 6e64 ss tests in sand 00000910: 626f 7829 2077 6173 3a5c 225c 6e20 2020 box) was:\"\n 00000920: 2020 2020 2070 7269 6e74 6620 5c22 2573 printf \"%s 00000930: 5c5c 6e5c 2220 5c22 2d2d 2d2d 2d2d 2d5c \\n\" \"-------\ 00000940: 225c 6e20 2020 2020 2020 2063 6174 206c "\n cat l 00000950: 6f67 726f 7461 7465 2e63 6f6e 665c 6e20 ogrotate.conf\n 00000960: 2020 2020 2020 2070 7269 6e74 6620 5c22 printf \" 00000970: 2573 5c5c 6e5c 2220 5c22 2d2d 2d2d 2d2d %s\\n\" \"------ 00000980: 2d5c 225c 6e20 2020 2020 2020 2065 6368 -\"\n ech 00000990: 6f20 5c22 5468 6520 6572 726f 7220 7265 o \"The error re 000009a0: 706f 7274 6564 2062 7920 6c6f 6772 6f74 ported by logrot 000009b0: 6174 6520 7761 7320 6173 2066 6f6c 6c6f ate was as follo 000009c0: 773a 5c22 5c6e 2020 2020 2020 2020 7072 w:\"\n pr 000009d0: 696e 7466 205c 2225 735c 5c6e 5c22 205c intf \"%s\\n\" \ 000009e0: 222d 2d2d 2d2d 2d2d 5c22 5c6e 2020 2020 "-------\"\n 000009f0: 2020 2020 6361 7420 6c6f 6772 6f74 6174 cat logrotat 00000a00: 652d 6572 726f 725c 6e20 2020 2020 2020 e-error\n 00000a10: 2070 7269 6e74 6620 5c22 2573 5c5c 6e5c printf \"%s\\n\ 00000a20: 2220 5c22 2d2d 2d2d 2d2d 2d5c 225c 6e20 " \"-------\"\n 00000a30: 2020 2020 2020 2065 6368 6f20 5c22 596f echo \"Yo 00000a40: 7520 6361 6e20 6469 7361 626c 6520 7468 u can disable th 00000a50: 6973 2063 6865 636b 2077 6974 6820 7365 is check with se 00000a60: 7276 6963 6573 2e6c 6f67 726f 7461 7465 rvices.logrotate 00000a70: 2e63 6865 636b 436f 6e66 6967 203d 2066 .checkConfig = f 00000a80: 616c 7365 2c5c 225c 6e20 2020 2020 2020 alse,\"\n 00000a90: 2065 6368 6f20 5c22 6275 7420 6966 2079 echo \"but if y 00000aa0: 6f75 2074 6869 6e6b 2069 7420 7368 6f75 ou think it shou 00000ab0: 6c64 2077 6f72 6b20 706c 6561 7365 2072 ld work please r 00000ac0: 6570 6f72 7420 7468 6973 2066 6169 6c75 eport this failu 00000ad0: 7265 2061 6c6f 6e67 2077 6974 685c 225c re along with\"\ 00000ae0: 6e20 2020 2020 2020 2065 6368 6f20 5c22 n echo \" 00000af0: 7468 6520 636f 6e66 6967 2066 696c 6520 the config file 00000b00: 6265 696e 6720 7465 7374 6564 215c 225c being tested!\"\ 00000b10: 6e20 2020 2020 2020 2066 616c 7365 5c6e n false\n 00000b20: 6669 5c6e 2229 2c28 2263 6d61 6b65 466c fi\n"),("cmakeFl 00000b30: 6167 7322 2c22 2229 2c28 2263 6f6e 6669 ags",""),("confi 00000b40: 6775 7265 466c 6167 7322 2c22 2229 2c28 gureFlags",""),( 00000b50: 2264 6570 7342 7569 6c64 4275 696c 6422 "depsBuildBuild" 00000b60: 2c22 2229 2c28 2264 6570 7342 7569 6c64 ,""),("depsBuild 00000b70: 4275 696c 6450 726f 7061 6761 7465 6422 BuildPropagated" 00000b80: 2c22 2229 2c28 2264 6570 7342 7569 6c64 ,""),("depsBuild 00000b90: 5461 7267 6574 222c 2222 292c 2822 6465 Target",""),("de 00000ba0: 7073 4275 696c 6454 6172 6765 7450 726f psBuildTargetPro 00000bb0: 7061 6761 7465 6422 2c22 2229 2c28 2264 pagated",""),("d 00000bc0: 6570 7348 6f73 7448 6f73 7422 2c22 2229 epsHostHost","") 00000bd0: 2c28 2264 6570 7348 6f73 7448 6f73 7450 ,("depsHostHostP 00000be0: 726f 7061 6761 7465 6422 2c22 2229 2c28 ropagated",""),( 00000bf0: 2264 6570 7354 6172 6765 7454 6172 6765 "depsTargetTarge 00000c00: 7422 2c22 2229 2c28 2264 6570 7354 6172 t",""),("depsTar 00000c10: 6765 7454 6172 6765 7450 726f 7061 6761 getTargetPropaga 00000c20: 7465 6422 2c22 2229 2c28 2264 6f43 6865 ted",""),("doChe 00000c30: 636b 222c 2222 292c 2822 646f 496e 7374 ck",""),("doInst 00000c40: 616c 6c43 6865 636b 222c 2222 292c 2822 allCheck",""),(" 00000c50: 656e 6162 6c65 5061 7261 6c6c 656c 4275 enableParallelBu 00000c60: 696c 6469 6e67 222c 2231 2229 2c28 2265 ilding","1"),("e 00000c70: 6e61 626c 6550 6172 616c 6c65 6c43 6865 nableParallelChe 00000c80: 636b 696e 6722 2c22 3122 292c 2822 656e cking","1"),("en 00000c90: 6162 6c65 5061 7261 6c6c 656c 496e 7374 ableParallelInst 00000ca0: 616c 6c69 6e67 222c 2231 2229 2c28 2265 alling","1"),("e 00000cb0: 7865 6375 7461 626c 6522 2c22 2229 2c28 xecutable",""),( 00000cc0: 226d 6573 6f6e 466c 6167 7322 2c22 2229 "mesonFlags","") 00000cd0: 2c28 226e 616d 6522 2c22 6c6f 6772 6f74 ,("name","logrot 00000ce0: 6174 652e 636f 6e66 2229 2c28 226e 6174 ate.conf"),("nat 00000cf0: 6976 6542 7569 6c64 496e 7075 7473 222c iveBuildInputs", 00000d00: 2222 292c 2822 6f75 7422 2c22 2f6e 6978 ""),("out","/nix 00000d10: 2f73 746f 7265 2f62 6e37 6471 3436 306a /store/bn7dq460j 00000d20: 6a66 3761 377a 7961 7232 6c38 7778 3636 jf7a7zyar2l8wx66 00000d30: 617a 336a 646b 312d 6c6f 6772 6f74 6174 az3jdk1-logrotat 00000d40: 652e 636f 6e66 2229 2c28 226f 7574 7075 e.conf"),("outpu 00000d50: 7473 222c 226f 7574 2229 2c28 2270 6173 ts","out"),("pas 00000d60: 7341 7346 696c 6522 2c22 6275 696c 6443 sAsFile","buildC 00000d70: 6f6d 6d61 6e64 2074 6578 7422 292c 2822 ommand text"),(" 00000d80: 7061 7463 6865 7322 2c22 2229 2c28 2270 patches",""),("p 00000d90: 7265 6665 724c 6f63 616c 4275 696c 6422 referLocalBuild" 00000da0: 2c22 3122 292c 2822 7072 6f70 6167 6174 ,"1"),("propagat 00000db0: 6564 4275 696c 6449 6e70 7574 7322 2c22 edBuildInputs"," 00000dc0: 2229 2c28 2270 726f 7061 6761 7465 644e "),("propagatedN 00000dd0: 6174 6976 6542 7569 6c64 496e 7075 7473 ativeBuildInputs 00000de0: 222c 2222 292c 2822 7374 6465 6e76 222c ",""),("stdenv", 00000df0: 222f 6e69 782f 7374 6f72 652f 7070 7935 "/nix/store/ppy5 00000e00: 676d 3672 3637 3663 6864 6135 6967 3578 gm6r676chda5ig5x 00000e10: 6762 6872 3873 6233 7266 6170 2d73 7464 gbhr8sb3rfap-std 00000e20: 656e 762d 6c69 6e75 7822 292c 2822 7374 env-linux"),("st 00000e30: 7269 6374 4465 7073 222c 2222 292c 2822 rictDeps",""),(" 00000e40: 7379 7374 656d 222c 2278 3836 5f36 342d system","x86_64- 00000e50: 6c69 6e75 7822 292c 2822 7465 7874 222c linux"),("text", 00000e60: 2277 6565 6b6c 795c 6e6d 6973 7369 6e67 "weekly\nmissing 00000e70: 6f6b 5c6e 6e6f 7469 6665 6d70 7479 5c6e ok\nnotifempty\n 00000e80: 726f 7461 7465 2034 5c6e 5c6e 5c22 2f76 rotate 4\n\n\"/v 00000e90: 6172 2f6c 6f67 2f62 746d 705c 2220 7b5c ar/log/btmp\" {\ 00000ea0: 6e20 2063 7265 6174 6520 3036 3630 2072 n create 0660 r 00000eb0: 6f6f 7420 7574 6d70 5c6e 2020 6d6f 6e74 oot utmp\n mont 00000ec0: 686c 795c 6e20 206d 696e 7369 7a65 2031 hly\n minsize 1 00000ed0: 4d5c 6e20 2072 6f74 6174 6520 315c 6e7d M\n rotate 1\n} 00000ee0: 5c6e 5c6e 5c22 2f76 6172 2f6c 6f67 2f77 \n\n\"/var/log/w 00000ef0: 746d 705c 2220 7b5c 6e20 2063 7265 6174 tmp\" {\n creat 00000f00: 6520 3036 3634 2072 6f6f 7420 7574 6d70 e 0664 root utmp 00000f10: 5c6e 2020 6d6f 6e74 686c 795c 6e20 206d \n monthly\n m 00000f20: 696e 7369 7a65 2031 4d5c 6e20 2072 6f74 insize 1M\n rot 00000f30: 6174 6520 315c 6e7d 5c6e 2229 5d29 ate 1\n}\n")]) ``` </details> ``` nix --version nix (Lix, like Nix) 2.90.0-lixpre20240506-f75d075 ```
jade added the
bug
label 2024-05-08 06:51:49 +00:00
Member

This looks like it could be arguments being treated as roots. What platform is this on?

This looks like it could be arguments being treated as roots. What platform is this on?
Member

hmm I'm seeing the opposite issue(?): I cannot delete the .drv, but I can delete the build artifact first (what's the proper name for that?) and then the .drv. this might just be expected behavior? i don't know

like, it makes sense that --referrers prevent GC, so maybe --outputs do too …

nonetheless, it would be great to have a --why-no-delete command, since --roots isn't the full issue when deleting individual paths

λ nix --version
nix (Lix, like Nix) 2.90.0-lixpre20240504-8dfb30a

λ nix-store --add logrotate.conf.drv 
/nix/store/89j4jgilyw0wyjip1yf1ai6d2fqhm8zm-logrotate.conf.drv

λ nix-store --realise /nix/store/89j4jgilyw0wyjip1yf1ai6d2fqhm8zm-logrotate.conf.drv
...
/nix/store/bn7dq460jjf7a7zyar2l8wx66az3jdk1-logrotate.conf

λ nix-store --delete /nix/store/89j4jgilyw0wyjip1yf1ai6d2fqhm8zm-logrotate.conf.drv
finding garbage collector roots...
0 store paths deleted, 0.00 MiB freed
error: Cannot delete path '/nix/store/89j4jgilyw0wyjip1yf1ai6d2fqhm8zm-logrotate.conf.drv' since it is still alive. To find out why, use: nix-store --query --roots

λ nix-store --query --roots /nix/store/89j4jgilyw0wyjip1yf1ai6d2fqhm8zm-logrotate.conf.drv

λ nix-store --query --referrers /nix/store/89j4jgilyw0wyjip1yf1ai6d2fqhm8zm-logrotate.conf.drv

λ nix-store --query --outputs /nix/store/89j4jgilyw0wyjip1yf1ai6d2fqhm8zm-logrotate.conf.drv
/nix/store/bn7dq460jjf7a7zyar2l8wx66az3jdk1-logrotate.conf

λ nix-store --query --deriver /nix/store/bn7dq460jjf7a7zyar2l8wx66az3jdk1-logrotate.conf
/nix/store/89j4jgilyw0wyjip1yf1ai6d2fqhm8zm-logrotate.conf.drv

λ nix-store --query --roots /nix/store/bn7dq460jjf7a7zyar2l8wx66az3jdk1-logrotate.conf

λ nix-store --query --referrers /nix/store/bn7dq460jjf7a7zyar2l8wx66az3jdk1-logrotate.conf

λ nix-store --delete /nix/store/bn7dq460jjf7a7zyar2l8wx66az3jdk1-logrotate.conf
finding garbage collector roots...
deleting '/nix/store/bn7dq460jjf7a7zyar2l8wx66az3jdk1-logrotate.conf'
deleting unused links...
note: currently hard linking saves 945.69 MiB
1 store paths deleted, 0.00 MiB freed

λ nix-store --delete /nix/store/89j4jgilyw0wyjip1yf1ai6d2fqhm8zm-logrotate.conf.drv 
finding garbage collector roots...
deleting '/nix/store/89j4jgilyw0wyjip1yf1ai6d2fqhm8zm-logrotate.conf.drv'
deleting unused links...
note: currently hard linking saves 945.69 MiB
1 store paths deleted, 0.00 MiB freed
hmm I'm seeing the opposite issue(?): I cannot delete the `.drv`, but I can delete the build artifact first (what's the proper name for that?) and then the `.drv`. this might just be expected behavior? i don't know like, it makes sense that `--referrers` prevent GC, so maybe `--outputs` do too … nonetheless, it would be great to have a `--why-no-delete` command, since `--roots` isn't the full issue when deleting individual paths <details> ``` λ nix --version nix (Lix, like Nix) 2.90.0-lixpre20240504-8dfb30a λ nix-store --add logrotate.conf.drv /nix/store/89j4jgilyw0wyjip1yf1ai6d2fqhm8zm-logrotate.conf.drv λ nix-store --realise /nix/store/89j4jgilyw0wyjip1yf1ai6d2fqhm8zm-logrotate.conf.drv ... /nix/store/bn7dq460jjf7a7zyar2l8wx66az3jdk1-logrotate.conf λ nix-store --delete /nix/store/89j4jgilyw0wyjip1yf1ai6d2fqhm8zm-logrotate.conf.drv finding garbage collector roots... 0 store paths deleted, 0.00 MiB freed error: Cannot delete path '/nix/store/89j4jgilyw0wyjip1yf1ai6d2fqhm8zm-logrotate.conf.drv' since it is still alive. To find out why, use: nix-store --query --roots λ nix-store --query --roots /nix/store/89j4jgilyw0wyjip1yf1ai6d2fqhm8zm-logrotate.conf.drv λ nix-store --query --referrers /nix/store/89j4jgilyw0wyjip1yf1ai6d2fqhm8zm-logrotate.conf.drv λ nix-store --query --outputs /nix/store/89j4jgilyw0wyjip1yf1ai6d2fqhm8zm-logrotate.conf.drv /nix/store/bn7dq460jjf7a7zyar2l8wx66az3jdk1-logrotate.conf λ nix-store --query --deriver /nix/store/bn7dq460jjf7a7zyar2l8wx66az3jdk1-logrotate.conf /nix/store/89j4jgilyw0wyjip1yf1ai6d2fqhm8zm-logrotate.conf.drv λ nix-store --query --roots /nix/store/bn7dq460jjf7a7zyar2l8wx66az3jdk1-logrotate.conf λ nix-store --query --referrers /nix/store/bn7dq460jjf7a7zyar2l8wx66az3jdk1-logrotate.conf λ nix-store --delete /nix/store/bn7dq460jjf7a7zyar2l8wx66az3jdk1-logrotate.conf finding garbage collector roots... deleting '/nix/store/bn7dq460jjf7a7zyar2l8wx66az3jdk1-logrotate.conf' deleting unused links... note: currently hard linking saves 945.69 MiB 1 store paths deleted, 0.00 MiB freed λ nix-store --delete /nix/store/89j4jgilyw0wyjip1yf1ai6d2fqhm8zm-logrotate.conf.drv finding garbage collector roots... deleting '/nix/store/89j4jgilyw0wyjip1yf1ai6d2fqhm8zm-logrotate.conf.drv' deleting unused links... note: currently hard linking saves 945.69 MiB 1 store paths deleted, 0.00 MiB freed ``` </details>
Author
Owner

oh, i see, yes this reproduces on my other machine now. it looks like it was an important step to actually run the build in order to cause this problem. so what we are actually experiencing is that if you nix store delete a .drv which has been built already and has output paths, it will fail to delete.

should we just like, make it work by deleting the outputs? i don't see immediately why one would not do that, but there might be a reason.

alternatively we could report a better error. i can kind of buy the argument that nix store delete should not delete dependents, but nix store delete's current semantics when an output is live make absolutely no sense, since according to the manual, --ignore-liveness means ignore roots, not ignore everything. Why is the

    With the option --ignore-liveness, reachability from the roots is ignored. However, the path still won't be deleted if there
    are other paths in the store that refer to it (i.e., depend on it).

But clearly this is bogus! You can nix store delete --ignore-liveness and the output remains there afterwards, seemingly violating an invariant. This seems like it actually should not be allowed to begin with, in addition to the UX issue we found here.

*oh*, i see, yes this reproduces on my other machine now. it looks like it was an important step to actually run the build in order to cause this problem. so what we are actually experiencing is that if you `nix store delete` a `.drv` which has been built already and has output paths, it will fail to delete. should we just like, make it work by deleting the outputs? i don't see immediately why one would not do that, but there might be a reason. alternatively we could report a better error. i can kind of buy the argument that `nix store delete` should not delete dependents, but `nix store delete`'s current semantics when an *output* is live make absolutely no sense, since according to the manual, `--ignore-liveness` means *ignore roots*, not *ignore everything*. Why is the ``` With the option --ignore-liveness, reachability from the roots is ignored. However, the path still won't be deleted if there are other paths in the store that refer to it (i.e., depend on it). ``` But clearly this is bogus! You can `nix store delete --ignore-liveness` and the output remains there afterwards, seemingly violating an invariant. This seems like it actually should not be allowed to begin with, in addition to the UX issue we found here.
Author
Owner

hm, ok it does not violate an invariant at least: i realised a path that is not on my system without doing it from an evaluation (i know it is not on this system because it is a different architecture).

~ » nix-store --realise /nix/store/jxbhlfpqvgljyrb0qkdwh50dx6y31ksw-bash-interactive-5.2p26/bin/bash
<...>
~ » nix-store --query --deriver /nix/store/jxbhlfpqvgljyrb0qkdwh50dx6y31ksw-bash-interactive-5.2p26
/nix/store/vdw3gpq9i64zar8r4xsa4b0jb6n7lrlk-bash-interactive-5.2p26.drv
~ » ls /nix/store/vdw3gpq9i64zar8r4xsa4b0jb6n7lrlk-bash-interactive-5.2p26.drv
ls: cannot access '/nix/store/vdw3gpq9i64zar8r4xsa4b0jb6n7lrlk-bash-interactive-5.2p26.drv': No such file or directory

so then, should nix store delete just ignore outputs when deleting derivations and simply delete them properly by default? should it delete also the outputs? i don't know! i would also like to have a "gc this path please, delete its dependents for me uwu" command, which sounds like a horribly dangerous footgun, but if it only works on unrooted paths, it should probably be fine right?

hm, ok it does not violate an invariant at least: i realised a path that is not on my system without doing it from an evaluation (i know it is not on this system because it is a different architecture). ``` ~ » nix-store --realise /nix/store/jxbhlfpqvgljyrb0qkdwh50dx6y31ksw-bash-interactive-5.2p26/bin/bash <...> ~ » nix-store --query --deriver /nix/store/jxbhlfpqvgljyrb0qkdwh50dx6y31ksw-bash-interactive-5.2p26 /nix/store/vdw3gpq9i64zar8r4xsa4b0jb6n7lrlk-bash-interactive-5.2p26.drv ~ » ls /nix/store/vdw3gpq9i64zar8r4xsa4b0jb6n7lrlk-bash-interactive-5.2p26.drv ls: cannot access '/nix/store/vdw3gpq9i64zar8r4xsa4b0jb6n7lrlk-bash-interactive-5.2p26.drv': No such file or directory ``` so then, should `nix store delete` just ignore outputs when deleting derivations and simply delete them properly by default? should it delete also the outputs? i don't know! i would also like to have a "gc this path please, delete its dependents for me uwu" command, which sounds like a horribly dangerous footgun, but if it only works on unrooted paths, it should probably be fine right?
Author
Owner

This looks like it could be arguments being treated as roots. What platform is this on?

aha, yes, this is the sudo issue referenced at the top of the bug here. we should probably file another bug for that one: the sudo environment does get caught as a root on linux, which is rather cursed to be honest.

however it wasn't at play because we noticed it and used an interactive root shell.

> This looks like it could be arguments being treated as roots. What platform is this on? aha, yes, this is the sudo issue referenced at the top of the bug here. we should probably file another bug for that one: the sudo environment does get caught as a root on linux, which is rather cursed to be honest. however it wasn't at play because we noticed it and used an interactive root shell.
Author
Owner

has been noted that keep-outputs and keep-derivations may be at play in making this error especially terrible.

has been noted that keep-outputs and keep-derivations may be at play in making this error especially terrible.
Author
Owner
https://github.com/NixOS/nix/pull/10733 hey a fix, hi alyssa
Author
Owner

Self-references?

lix/lix3 » nix-store --query --referrers /nix/store/7nfrwn7hh3p1jlx32b0ylvx2jcnxf07g-nixos-test-driver-nix-copy-closure
/nix/store/7nfrwn7hh3p1jlx32b0ylvx2jcnxf07g-nixos-test-driver-nix-copy-closure
lix/lix3 » nix-store --query --roots /nix/store/7nfrwn7hh3p1jlx32b0ylvx2jcnxf07g-nixos-test-driver-nix-copy-closure
lix/lix3 » nix store delete /nix/store/7nfrwn7hh3p1jlx32b0ylvx2jcnxf07g-nixos-test-driver-nix-copy-closure
0 store paths deleted, 0.00 MiB freed
error: Cannot delete path '/nix/store/7nfrwn7hh3p1jlx32b0ylvx2jcnxf07g-nixos-test-driver-nix-copy-closure' since it is still alive. To find out why, use: nix-store --query --roots and nix-store --query --referrers
Self-references? ``` lix/lix3 » nix-store --query --referrers /nix/store/7nfrwn7hh3p1jlx32b0ylvx2jcnxf07g-nixos-test-driver-nix-copy-closure /nix/store/7nfrwn7hh3p1jlx32b0ylvx2jcnxf07g-nixos-test-driver-nix-copy-closure lix/lix3 » nix-store --query --roots /nix/store/7nfrwn7hh3p1jlx32b0ylvx2jcnxf07g-nixos-test-driver-nix-copy-closure lix/lix3 » nix store delete /nix/store/7nfrwn7hh3p1jlx32b0ylvx2jcnxf07g-nixos-test-driver-nix-copy-closure 0 store paths deleted, 0.00 MiB freed error: Cannot delete path '/nix/store/7nfrwn7hh3p1jlx32b0ylvx2jcnxf07g-nixos-test-driver-nix-copy-closure' since it is still alive. To find out why, use: nix-store --query --roots and nix-store --query --referrers ```
Author
Owner

There are self-references.

There *are* self-references.
Author
Owner

The original bug above is caused by the output being present on the system, which is referencing the derivation, possibly due to keep-derivations. The error message is just as awful as before, though. It does not reproduce if the derivation is not realised.

Accordingly, here is a trivial reproducer:

lix/lix3 » nix build -f trivial.nix --print-out-paths --no-link
/nix/store/1s708s1g3hkznawqr442nlb6igvpa1jh-trivial
lix/lix3 » nix-store --query --deriver /nix/store/1s708s1g3hkznawqr442nlb6igvpa1jh-trivial
/nix/store/l89r7n5fwi1i97fv1ah5k5gkdis8nyy9-trivial.drv
lix/lix3 » nix-store --delete /nix/store/l89r7n5fwi1i97fv1ah5k5gkdis8nyy9-trivial.drv
finding garbage collector roots...
0 store paths deleted, 0.00 MiB freed
error: Cannot delete path '/nix/store/l89r7n5fwi1i97fv1ah5k5gkdis8nyy9-trivial.drv' since it is still alive. To find out why, use: nix-store --query --roots and nix-store --query --referrers
lix/lix3 » nix-store --query --roots /nix/store/l89r7n5fwi1i97fv1ah5k5gkdis8nyy9-trivial.drv
lix/lix3 » nix-store --query --referrers /nix/store/l89r7n5fwi1i97fv1ah5k5gkdis8nyy9-trivial.drv
lix/lix3 » cat trivial.nix
builtins.derivation {
  name = "trivial";
  system = "x86_64-linux";
  builder = "/bin/sh";
  args = ["-c" "echo meow > $out"];
}

The behaviour I would expect is that at least one of the listed commands would correctly list the referrers from a gc perspective. Perhaps also that the failure would actually say which paths were referring to it.

The original bug above is caused by the output being present on the system, which is referencing the derivation, possibly due to `keep-derivations`. The error message is just as awful as before, though. It does not reproduce if the derivation is not realised. Accordingly, here is a trivial reproducer: ``` lix/lix3 » nix build -f trivial.nix --print-out-paths --no-link /nix/store/1s708s1g3hkznawqr442nlb6igvpa1jh-trivial lix/lix3 » nix-store --query --deriver /nix/store/1s708s1g3hkznawqr442nlb6igvpa1jh-trivial /nix/store/l89r7n5fwi1i97fv1ah5k5gkdis8nyy9-trivial.drv lix/lix3 » nix-store --delete /nix/store/l89r7n5fwi1i97fv1ah5k5gkdis8nyy9-trivial.drv finding garbage collector roots... 0 store paths deleted, 0.00 MiB freed error: Cannot delete path '/nix/store/l89r7n5fwi1i97fv1ah5k5gkdis8nyy9-trivial.drv' since it is still alive. To find out why, use: nix-store --query --roots and nix-store --query --referrers lix/lix3 » nix-store --query --roots /nix/store/l89r7n5fwi1i97fv1ah5k5gkdis8nyy9-trivial.drv lix/lix3 » nix-store --query --referrers /nix/store/l89r7n5fwi1i97fv1ah5k5gkdis8nyy9-trivial.drv lix/lix3 » cat trivial.nix builtins.derivation { name = "trivial"; system = "x86_64-linux"; builder = "/bin/sh"; args = ["-c" "echo meow > $out"]; } ``` The behaviour I would expect is that at least one of the listed commands would correctly list the referrers from a gc perspective. Perhaps also that the failure would actually say which paths were referring to it.
jade changed title from `nix-store --delete` fails without there being any discernable roots in `nix-store --query --roots` to `nix-store --delete` fails to delete derivations whose outputs exist 2024-08-30 05:53:47 +00:00
jade added the
Area/store
label 2024-08-30 05:55:23 +00:00
Sign in to join this conversation.
No milestone
No project
No assignees
3 participants
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference: lix-project/lix#282
No description provided.