Skip to content

Commit e7a71ac

Browse files
authored
inheritCargoArtifactsHook: handle various new cargo lockfiles (#1066)
Cargo used to use `.cargo-lock` files but has recently started introducing more granular locks (like `.cargo-build-lock` and some others)
1 parent f7d151e commit e7a71ac

2 files changed

Lines changed: 10 additions & 4 deletions

File tree

CHANGELOG.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,9 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.
1515
### Fixed
1616
* `urlForCargoPackage` was fixed to correctly handle crate prefixes for crate
1717
names longer than 4 characters
18+
* Inheriting cargo artifacts produced via `installCargoArtifactsMode =
19+
"use-symlink"` now handle paths to cargo's newly introduced internal lock
20+
files
1821

1922
## [0.23.4] - 2026-05-17
2023

lib/setupHooks/inheritCargoArtifactsHook.sh

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -48,9 +48,9 @@ inheritCargoArtifacts() {
4848
# since the store is read-only and cargo would otherwise choke
4949
chmod -R u+w "${cargoTargetDir}"
5050

51-
# NB: cargo also doesn't like it if `.cargo-lock` files remain with a
51+
# NB: cargo also doesn't like it if various `.cargo*lock` files remain with a
5252
# timestamp in the distant past so we need to delete them here
53-
find "${cargoTargetDir}" -name '.cargo-lock' -delete
53+
find "${cargoTargetDir}" -name '.cargo*lock' -delete
5454
else
5555
# Dependency .rlib and .rmeta files are content addressed and thus are not written to after
5656
# being built (since changing `Cargo.lock` would rebuild everything anyway), which makes them
@@ -82,10 +82,13 @@ inheritCargoArtifacts() {
8282
# NB: `.cargo-lock` files tend to appear in "top level" profile artifact directories.
8383
# Those directories usually contain a `*.d` file for each binary target, but these are NOT
8484
# content addressed, so we will want to copy them directly so they become writable in place
85-
find "${cargoTargetDir}" -name '.cargo-lock' -delete \
85+
find "${cargoTargetDir}" -name '.cargo*lock' -delete \
8686
-execdir bash -c '
87+
set -x
8788
for f in *.d; do
88-
cp --preserve=timestamps --no-preserve=ownership --remove-destination "$(readlink "${f}")" "${f}"
89+
orig="$(readlink "${f}")"
90+
[[ -n "${orig}" ]] || continue
91+
cp --preserve=timestamps --no-preserve=ownership --remove-destination "${orig}" "${f}"
8992
chmod u+w "${f}"
9093
done
9194
' \;

0 commit comments

Comments
 (0)