mirror of https://github.com/astral-sh/uv
Avoid reading symlinks during `uv python install` on Windows (#10639)
Closes #10633
This commit is contained in:
parent
9736868908
commit
250b77e972
|
|
@ -362,28 +362,36 @@ pub(crate) async fn install(
|
|||
target.simplified_display()
|
||||
);
|
||||
|
||||
// Check if the existing link is valid
|
||||
let valid_link = target
|
||||
.read_link()
|
||||
.and_then(|target| target.try_exists())
|
||||
.inspect_err(|err| debug!("Failed to inspect executable with error: {err}"))
|
||||
.unwrap_or(true);
|
||||
|
||||
// Figure out what installation it references, if any
|
||||
let existing = valid_link
|
||||
.then(|| {
|
||||
find_matching_bin_link(
|
||||
installations
|
||||
.iter()
|
||||
.copied()
|
||||
.chain(existing_installations.iter()),
|
||||
&target,
|
||||
)
|
||||
})
|
||||
.flatten();
|
||||
let existing = find_matching_bin_link(
|
||||
installations
|
||||
.iter()
|
||||
.copied()
|
||||
.chain(existing_installations.iter()),
|
||||
&target,
|
||||
);
|
||||
|
||||
match existing {
|
||||
None => {
|
||||
// Determine if the link is valid, i.e., if it points to an existing
|
||||
// Python we don't manage.
|
||||
let valid_link = cfg!(unix)
|
||||
.then(|| {
|
||||
target
|
||||
.read_link()
|
||||
.and_then(|target| target.try_exists())
|
||||
.inspect_err(|err| {
|
||||
debug!(
|
||||
"Failed to inspect executable with error: {err}"
|
||||
);
|
||||
})
|
||||
// If we can't verify the link, assume it is valid.
|
||||
.unwrap_or(true)
|
||||
})
|
||||
// On Windows, we just assume it is valid because symlinks are not
|
||||
// common.
|
||||
.unwrap_or(true);
|
||||
|
||||
// There's an existing executable we don't manage, require `--force`
|
||||
if valid_link {
|
||||
if !force {
|
||||
|
|
|
|||
Loading…
Reference in New Issue