Skip to content

Commit 87edd5b

Browse files
committed
Keep stale yarn classic locks on yarn install advice
A registry-range yarn.lock block with no `resolved` is not a copy yarn installs from the working tree: it's a stale lock that `yarn install` re-locks. Treat it as before (generic vendor_lock_entry_not_found, no VEX block) instead of as a `file:` directory copy; only `file:`, `link:` and git blocks now trigger vendor_lock_entry_not_rewritable. Assisted-by: Claude Code:claude-opus-5-5
1 parent 8bb51ca commit 87edd5b

2 files changed

Lines changed: 34 additions & 23 deletions

File tree

‎crates/socket-patch-core/src/vendor/yarn_classic_lock.rs‎

Lines changed: 33 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -298,21 +298,30 @@ fn rewritable_candidates(
298298
) -> Result<(Vec<String>, Vec<VendorWarning>), Box<VendorOutcome>> {
299299
let mut candidate_keys: Vec<String> = Vec::new();
300300
let mut skipped: Vec<VendorWarning> = Vec::new();
301+
// The skipped blocks that are real installed copies no re-lock changes.
302+
let mut unrewritable: Vec<String> = Vec::new();
301303
for block in blocks {
302304
match classify_classic_block(block, name, version) {
303305
BlockClass::Candidate => candidate_keys.push(block.key.clone()),
304306
BlockClass::LinkSkip(detail) => {
307+
unrewritable.push(detail.clone());
308+
skipped.push(VendorWarning::new("vendor_link_entry_skipped", detail));
309+
}
310+
BlockClass::GitSkip(detail) => {
311+
unrewritable.push(detail.clone());
312+
skipped.push(VendorWarning::new(
313+
"vendor_yarn_classic_git_entry_skipped",
314+
detail,
315+
));
316+
}
317+
BlockClass::UnresolvedSkip(detail) => {
305318
skipped.push(VendorWarning::new("vendor_link_entry_skipped", detail));
306319
}
307-
BlockClass::GitSkip(detail) => skipped.push(VendorWarning::new(
308-
"vendor_yarn_classic_git_entry_skipped",
309-
detail,
310-
)),
311320
BlockClass::NoMatch => {}
312321
}
313322
}
314-
if candidate_keys.is_empty() && !skipped.is_empty() {
315-
let details: Vec<&str> = skipped.iter().map(|w| w.detail.as_str()).collect();
323+
if candidate_keys.is_empty() && !unrewritable.is_empty() {
324+
let details: Vec<&str> = unrewritable.iter().map(String::as_str).collect();
316325
return Err(Box::new(refused(
317326
"vendor_lock_entry_not_rewritable",
318327
format!(
@@ -686,6 +695,9 @@ enum BlockClass {
686695
/// Matches the target but yarn fetches it with git (#363); carries the
687696
/// warning detail.
688697
GitSkip(String),
698+
/// Matches the target but has no `resolved` (a stale lock `yarn install`
699+
/// re-locks); carries the warning detail.
700+
UnresolvedSkip(String),
689701
NoMatch,
690702
}
691703

@@ -713,19 +725,15 @@ fn classify_classic_block(block: &LockBlock, name: &str, version: &str) -> Block
713725
"lock block `{}` is a link: dependency; skipped",
714726
block.key
715727
)),
716-
ClassicBlockSource::Directory => BlockClass::LinkSkip(if resolved.is_none() {
717-
format!(
718-
"lock block `{}` has no resolved tarball (a file: directory copy); \
719-
skipped, so that copy stays unpatched",
720-
block.key
721-
)
722-
} else {
723-
format!(
724-
"lock block `{}` is a file: directory dependency; skipped, so that copy \
725-
stays unpatched",
726-
block.key
727-
)
728-
}),
728+
ClassicBlockSource::Directory => BlockClass::LinkSkip(format!(
729+
"lock block `{}` is a file: directory dependency; skipped, so that copy \
730+
stays unpatched",
731+
block.key
732+
)),
733+
ClassicBlockSource::Unresolved => BlockClass::UnresolvedSkip(format!(
734+
"lock block `{}` has no resolved tarball; skipped",
735+
block.key
736+
)),
729737
// yarn fetches a git pattern with git, from `resolved` (#363): a
730738
// vendored tarball there makes every install fail, and the copy is
731739
// the git bytes.
@@ -1084,11 +1092,14 @@ pub(crate) enum ClassicBlockSource {
10841092
Tarball,
10851093
/// A `link:` range: a symlink into the working tree.
10861094
Link,
1087-
/// A `file:` directory range, or no `resolved` at all: yarn COPIES the
1088-
/// directory into `node_modules`, so that copy keeps its own bytes.
1095+
/// A `file:` directory range: yarn COPIES the directory into
1096+
/// `node_modules`, so that copy keeps its own bytes.
10891097
Directory,
10901098
/// Fetched by yarn's git fetcher ([`classic_block_is_git`]).
10911099
Git,
1100+
/// Any other range with no `resolved`: not something yarn writes for a
1101+
/// locked package, so the lock is stale and `yarn install` re-locks it.
1102+
Unresolved,
10921103
}
10931104

10941105
/// [`ClassicBlockSource`] of a block from its key patterns and `resolved`.
@@ -1112,7 +1123,7 @@ pub(crate) fn classic_block_source(
11121123
}
11131124
match resolved {
11141125
Some(_) => ClassicBlockSource::Tarball,
1115-
None => ClassicBlockSource::Directory,
1126+
None => ClassicBlockSource::Unresolved,
11161127
}
11171128
}
11181129

‎crates/socket-patch-core/src/vex/discover/yarn.rs‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -240,7 +240,7 @@ fn classic_block(
240240
return;
241241
}
242242
// `link:` ranges install from the working tree; `resolved` is inert.
243-
ClassicBlockSource::Link => return,
243+
ClassicBlockSource::Link | ClassicBlockSource::Unresolved => return,
244244
ClassicBlockSource::Tarball => {}
245245
}
246246
let Some(resolved) = resolved else {

0 commit comments

Comments
 (0)