mirror of
https://github.com/NixOS/nix.git
synced 2025-12-07 01:21:00 +01:00
Merge pull request #130 from DeterminateSystems/improve-nix-store-delete-errors
nix store delete: Show why deletion fails
This commit is contained in:
commit
e809a5626e
7 changed files with 62 additions and 36 deletions
|
|
@ -9,6 +9,7 @@ mkDerivation {
|
|||
|
||||
cat > $out/program <<EOF
|
||||
#! ${shell}
|
||||
echo x > \$TEST_ROOT/fifo
|
||||
sleep 10000
|
||||
EOF
|
||||
|
||||
|
|
|
|||
|
|
@ -21,11 +21,16 @@ nix-env -p "$profiles/test" -f ./gc-runtime.nix -i gc-runtime
|
|||
outPath=$(nix-env -p "$profiles/test" -q --no-name --out-path gc-runtime)
|
||||
echo "$outPath"
|
||||
|
||||
fifo="$TEST_ROOT/fifo"
|
||||
mkfifo "$fifo"
|
||||
|
||||
echo "backgrounding program..."
|
||||
"$profiles"/test/program &
|
||||
sleep 2 # hack - wait for the program to get started
|
||||
"$profiles"/test/program "$fifo" &
|
||||
child=$!
|
||||
echo PID=$child
|
||||
cat "$fifo"
|
||||
|
||||
expectStderr 1 nix-store --delete "$outPath" | grepQuiet "Cannot delete path.*because it's referenced by the GC root '/proc/"
|
||||
|
||||
nix-env -p "$profiles/test" -e gc-runtime
|
||||
nix-env -p "$profiles/test" --delete-generations old
|
||||
|
|
|
|||
|
|
@ -23,10 +23,10 @@ if nix-store --gc --print-dead | grep -E "$outPath"$; then false; fi
|
|||
nix-store --gc --print-dead
|
||||
|
||||
inUse=$(readLink "$outPath/reference-to-input-2")
|
||||
if nix-store --delete "$inUse"; then false; fi
|
||||
expectStderr 1 nix-store --delete "$inUse" | grepQuiet "Cannot delete path.*because it's referenced by path '"
|
||||
test -e "$inUse"
|
||||
|
||||
if nix-store --delete "$outPath"; then false; fi
|
||||
expectStderr 1 nix-store --delete "$outPath" | grepQuiet "Cannot delete path.*because it's referenced by the GC root "
|
||||
test -e "$outPath"
|
||||
|
||||
for i in "$NIX_STORE_DIR"/*; do
|
||||
|
|
|
|||
|
|
@ -22,14 +22,14 @@ input2=$(nix-build ../hermetic.nix --no-out-link --arg busybox "$busybox" --arg
|
|||
input3=$(nix-build ../hermetic.nix --no-out-link --arg busybox "$busybox" --arg withFinalRefs true --arg seed 2 -A passthru.input3 -j0)
|
||||
|
||||
# Can't delete because referenced
|
||||
expectStderr 1 nix-store --delete $input1 | grepQuiet "Cannot delete path"
|
||||
expectStderr 1 nix-store --delete $input2 | grepQuiet "Cannot delete path"
|
||||
expectStderr 1 nix-store --delete $input3 | grepQuiet "Cannot delete path"
|
||||
expectStderr 1 nix-store --delete $input1 | grepQuiet "Cannot delete path.*because it's referenced by path"
|
||||
expectStderr 1 nix-store --delete $input2 | grepQuiet "Cannot delete path.*because it's referenced by path"
|
||||
expectStderr 1 nix-store --delete $input3 | grepQuiet "Cannot delete path.*because it's referenced by path"
|
||||
|
||||
# These same paths are referenced in the lower layer (by the seed 1
|
||||
# build done in `initLowerStore`).
|
||||
expectStderr 1 nix-store --store "$storeA" --delete $input2 | grepQuiet "Cannot delete path"
|
||||
expectStderr 1 nix-store --store "$storeA" --delete $input3 | grepQuiet "Cannot delete path"
|
||||
expectStderr 1 nix-store --store "$storeA" --delete $input2 | grepQuiet "Cannot delete path.*because it's referenced by path"
|
||||
expectStderr 1 nix-store --store "$storeA" --delete $input3 | grepQuiet "Cannot delete path.*because it's referenced by path"
|
||||
|
||||
# Can delete
|
||||
nix-store --delete $hermetic
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue