How to fix "error: path '/nix/store/**-source/flake.nix' does not exist"

I make a myflake.tar.xz from the flake directory myflake and run the flake tarball like this. (I repeat this step a lot of times successfully and it suddenly break.)

$ nix run -vvvvv file://$(readlink -f myflake.tar.xz )
evaluating file '<nix/derivation-internal.nix>'
using cache entry '{"_what":"tarballCache","url":"file://home/user/testing/tarball/myflake.tar.xz"}' -> '{"etag":"","lastModified":172328120,"treeHash":"aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"}'
using cache entry '{"_what":"treeHashToNarHash","treeHash":"aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"}' -> '{"narHash":"sha256-bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb"}'
source path 'Β«file://home/user/testing/tarball/myflake.tar.xzΒ»/' is uncacheable
copying 'Β«file://home/user/testing/tarball/myflake.tar.xzΒ»/' to the store...
performing daemon worker op: 7
acquiring write lock on '/nix/var/nix/temproots/288425'
performing daemon worker op: 26
got tree '/nix/store/cccccccccccccccccccccccccccccccc-source' from 'file://home/user/testing/tarball/myflake.tar.xz?narHash=sha256-bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb'
error: path '/nix/store/cccccccccccccccccccccccccccccccc-source/flake.nix' does not exist

The directory structure of myflake.tar.xz it like this

myflake
β”œβ”€β”€ config
β”‚   β”œβ”€β”€ file1
β”‚   β”œβ”€β”€ dir1
β”‚   β”œβ”€β”€ ...
β”‚   └── ...
β”œβ”€β”€ flake.lock
└── flake.nix

but the file structure of /nix/store/cccccccccccccccccccccccccccccccc-source is like this :

config
β”œβ”€β”€ file1
β”œβ”€β”€ dir1
β”œβ”€β”€ ...
└──...

I may make things wrong before once, in the tar -cf process not including the flake.nix, and ran the nix run command.
But now I checked the tarball with tar -tf, now it definitely contains the flake.nix.
But the error message never goes away. I do not know why.
I tried delete the path with nix store delete /nix/store/cccccccccccccccccccccccccccccccc-source but failed.
Thanks for your help!

Did you tar tf /home/user/testing/tarball/myflake.tar.xz specifically? It sure looks like that tarball isn’t as you expect.

1 Like

Yes you are right, I used a wrong command and the myflake root folder disappeared in the tarball, but the compression software (atool) help me auto generate the myflake folder in extraction and put all the things inside it.
When I use tar -xf to decompress, flake.lock, flake.nix and config folder is extracted in the current directory, which is wrong and should be all put in the myflake folder.
I use another proper compression command and the problem is solved, thanks!