diff --git a/crates/uv-python/src/managed.rs b/crates/uv-python/src/managed.rs index ad1dacac6..9ee72adda 100644 --- a/crates/uv-python/src/managed.rs +++ b/crates/uv-python/src/managed.rs @@ -847,7 +847,7 @@ fn executable_path_from_base( /// Create a link to a managed Python executable. /// /// If the file already exists at the link path, an error will be returned. -pub fn create_link_to_executable(link: &Path, executable: PathBuf) -> Result<(), Error> { +pub fn create_link_to_executable(link: &Path, executable: &Path) -> Result<(), Error> { let link_parent = link.parent().ok_or(Error::NoExecutableDirectory)?; fs_err::create_dir_all(link_parent).map_err(|err| Error::ExecutableDirectory { to: link_parent.to_path_buf(), @@ -856,20 +856,20 @@ pub fn create_link_to_executable(link: &Path, executable: PathBuf) -> Result<(), if cfg!(unix) { // Note this will never copy on Unix — we use it here to allow compilation on Windows - match symlink_or_copy_file(&executable, link) { + match symlink_or_copy_file(executable, link) { Ok(()) => Ok(()), Err(err) if err.kind() == io::ErrorKind::NotFound => { - Err(Error::MissingExecutable(executable.clone())) + Err(Error::MissingExecutable(executable.to_path_buf())) } Err(err) => Err(Error::LinkExecutable { - from: executable, + from: executable.to_path_buf(), to: link.to_path_buf(), err, }), } } else if cfg!(windows) { // TODO(zanieb): Install GUI launchers as well - let launcher = windows_python_launcher(&executable, false)?; + let launcher = windows_python_launcher(executable, false)?; // OK to use `std::fs` here, `fs_err` does not support `File::create_new` and we attach // error context anyway @@ -878,7 +878,7 @@ pub fn create_link_to_executable(link: &Path, executable: PathBuf) -> Result<(), std::fs::File::create_new(link) .and_then(|mut file| file.write_all(launcher.as_ref())) .map_err(|err| Error::LinkExecutable { - from: executable, + from: executable.to_path_buf(), to: link.to_path_buf(), err, }) diff --git a/crates/uv-virtualenv/src/virtualenv.rs b/crates/uv-virtualenv/src/virtualenv.rs index 822e8d7bb..5d3ab4a88 100644 --- a/crates/uv-virtualenv/src/virtualenv.rs +++ b/crates/uv-virtualenv/src/virtualenv.rs @@ -262,10 +262,10 @@ pub(crate) fn create( if cfg!(windows) { if using_minor_version_link { let target = scripts.join(WindowsExecutable::Python.exe(interpreter)); - create_link_to_executable(target.as_path(), executable_target.clone()) + create_link_to_executable(target.as_path(), &executable_target) .map_err(Error::Python)?; let targetw = scripts.join(WindowsExecutable::Pythonw.exe(interpreter)); - create_link_to_executable(targetw.as_path(), executable_target) + create_link_to_executable(targetw.as_path(), &executable_target) .map_err(Error::Python)?; } else { // Always copy `python.exe`. diff --git a/crates/uv/src/commands/python/install.rs b/crates/uv/src/commands/python/install.rs index 37d6a6777..e54c44424 100644 --- a/crates/uv/src/commands/python/install.rs +++ b/crates/uv/src/commands/python/install.rs @@ -768,7 +768,7 @@ fn create_bin_links( installation.executable(false) }; - match create_link_to_executable(&target, executable.clone()) { + match create_link_to_executable(&target, &executable) { Ok(()) => { debug!( "Installed executable at `{}` for {}", @@ -925,7 +925,7 @@ fn create_bin_links( .remove(&target); } - if let Err(err) = create_link_to_executable(&target, executable) { + if let Err(err) = create_link_to_executable(&target, &executable) { errors.push(( InstallErrorKind::Bin, installation.key().clone(), @@ -953,7 +953,7 @@ fn create_bin_links( errors.push(( InstallErrorKind::Bin, installation.key().clone(), - anyhow::Error::new(err), + Error::new(err), )); } }