racket2nix icon indicating copy to clipboard operation
racket2nix copied to clipboard

Problem: raco pkg install can't handle dangling symlinks

Open clacke opened this issue 7 years ago • 4 comments

$ 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.

clacke avatar Mar 31 '18 02:03 clacke

Alternatively one could check using the -L bash feature to check for symlinks.

sjmackenzie avatar Mar 31 '18 03:03 sjmackenzie

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.

clacke avatar Mar 31 '18 03:03 clacke

This, but replace -print with -delete, should do it:

$ tree
.
├── asdf -> asdffff
├── asdffff
└── qwer -> xzcv
$ find . -type l -exec test '!' -e {} ';' -print
./qwer

clacke avatar Mar 31 '18 04:03 clacke

Just add a dangling symlink in nix/test/dangling-symlink -> road-to-nowhere to test for this.

clacke avatar Mar 31 '18 04:03 clacke