Problem: raco pkg install can't handle dangling symlinks
$ ln -s asdfasdfasdf nix/asdf
$ make
copy-directory/files: encountered path that is neither file nor directory [18/1069]
path: ./nix/asdf
context...:
/nix/store/pv5fnjv97wprb5p913xrcnqyrbb993m1-racket-minimal-6.12/share/racket/collects/racket/file.
rkt:90:21
/nix/store/pv5fnjv97wprb5p913xrcnqyrbb993m1-racket-minimal-6.12/share/racket/collects/racket/file.
rkt:76:2: loop
/nix/store/pv5fnjv97wprb5p913xrcnqyrbb993m1-racket-minimal-6.12/share/racket/collects/pkg/private/
stage.rkt:107:0: stage-package/info46
/nix/store/pv5fnjv97wprb5p913xrcnqyrbb993m1-racket-minimal-6.12/share/racket/collects/pkg/private/
install.rkt:659:4: for-loop
A concrete, non-contrived example would be the result links that nix-build leaves lying around, and which are dangling when in the build sandbox.
Solution: Remove all dangling symlinks in postUnpack.
Alternatively one could check using the -L bash feature to check for symlinks.
We need to allow symlinks, people might use those. It's only dangling symlinks that install gets upset about.
To check for dangling symlinks with bash [] or [[]], one would use -e for existence. But it's probably best to outsource the traversing of the directory to find with the right parameters.
This, but replace -print with -delete, should do it:
$ tree
.
├── asdf -> asdffff
├── asdffff
└── qwer -> xzcv
$ find . -type l -exec test '!' -e {} ';' -print
./qwer
Just add a dangling symlink in nix/test/dangling-symlink -> road-to-nowhere to test for this.