Skip to content

Building a crate that contains dangling symlinks fails #376590

@rolfschr

Description

This cp fails if the tree contains symlinks that cannot be derefenced (-L).

A real world use case can be found at #361181.

This allows to work around the issue:

diff --git a/pkgs/build-support/rust/import-cargo-lock.nix b/pkgs/build-support/rust/import-cargo-lock.nix
index e88931d0f383..5613248b4959 100644
--- a/pkgs/build-support/rust/import-cargo-lock.nix
+++ b/pkgs/build-support/rust/import-cargo-lock.nix
@@ -149,6 +149,10 @@ let
               inherit (gitParts) url;
               rev = gitParts.sha; # The commit SHA is always available.
               sha256 = gitShaOutputHash.${gitParts.sha};
+              postFetch = ''
+                # Find and remove dangling symlinks.
+                find $out -xtype l -print -delete
+              '';
             }
           else if allowBuiltinFetchGit then
             builtins.fetchGit {

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions