nix-prefetch icon indicating copy to clipboard operation
nix-prefetch copied to clipboard

Path is invalid

Open colinxs opened this issue 3 years ago • 0 comments

Ran across what I think is a bug while debugging a invalidPath error with cachix. From what I understand, nix-prefetch works by building with a fake sha256, letting the build fail, and then extracting the correct sha256. This has the side effect of leaving invalid paths in the store. Take the following for example (clean install).

> ls /nix/store | grep versions.json
# nothing
> nix-prefetch pkgs.fetchurl --url https://julialang-s3.julialang.org/bin/versions.json > /dev/null
> ls /nix/store | grep versions.json
7rdyclssbgcfwvhmcwp3aqcqyfmbb9ys-versions.json.lock
ha94j211qk3vh124irxc9qc801754hzf-versions.json
ha94j211qk3vh124irxc9qc801754hzf-versions.json.lock
> nix store verify /nix/store/ha94j211qk3vh124irxc9qc801754hzf-versions.json
> nix store verify /nix/store/7rdyclssbgcfwvhmcwp3aqcqyfmbb9ys-versions.json
error: path '/nix/store/7rdyclssbgcfwvhmcwp3aqcqyfmbb9ys-versions.json' is not valid

So it looks like the 7rdyclssbgcfwvhmcwp3aqcqyfmbb9ys-versions.json.lock is from the failed build with the fake sha256. Cachix throws an error when it sees this because, well, it's invalid. They should probably read paths from nix-store --dump-db but is deleting/preventing the invalid store path within the scope of nix-prefetch?

nix-prefetch-{git,url,etc} don't leave invalid paths behind, for comparison.

colinxs avatar May 24 '21 06:05 colinxs