Repository navigation
Conversation
| Self::LockMismatch(_, _, _, lockfile) if lockfile != "uv.lock" => { | ||
| let script = lockfile.strip_suffix(".lock").unwrap_or(lockfile); | ||
| uv_errors::Hints::from(format!( | ||
| "To update the lockfile, run `uv lock --script {script}`." | ||
| )) | ||
| } |
There was a problem hiding this comment.
This is a bit weird. It suggests we shouldn't pass through lockfile as a string but rather information which identifies if it's a script and the script path?
There was a problem hiding this comment.
which is maybe the Target or something?
There was a problem hiding this comment.
Good call. I replaced the string inference with an owned lock-target kind carrying the script path, and use that path to construct a safely quoted --script hint. Added coverage for a nested script with spaces in its filename.
e8e1463 to
10ace64
Compare
| /// An owned lock target for use in diagnostics. | ||
| #[derive(Debug, Clone)] | ||
| pub(crate) enum LockTargetKind { | ||
| Workspace, | ||
| Script(PathBuf), | ||
| } |
There was a problem hiding this comment.
Do we not have a concept for this elsewhere?
There was a problem hiding this comment.
I checked the existing targets. LockTarget and the similar TreeJsonTarget both borrow the workspace/script, while this error is propagated through anyhow and must own the script path. The other project targets own full parsed projects/scripts and are command-specific. I kept the small owned lock-target kind here to avoid cloning those structures or widening the lock API.
There was a problem hiding this comment.
Let's make sure to have that be in the /// doc comment referencing LockTarget plz
There was a problem hiding this comment.
Addressed on the current branch head: the LockTargetKind doc comment now references LockTarget and explains that lock-mismatch diagnostics cannot retain its borrowed target.
Stale script-lock diagnostics refer to
uv.lockand suggestuv lock, directing users to update the wrong file. Render the actual script lock and script-aware repair command; quote paths safely so spaces and shell metacharacters cannot make the hint unusable. This completes the target-specific guidance after script-lock support in uv#18832 and lock hints in uv#20219.Promoted upstream: astral-sh/uv#20439.