Use fs_err for paths in symlinking errors (#13303)
Some checks are pending
CI / build binary | linux musl (push) Blocked by required conditions
CI / build binary | macos aarch64 (push) Blocked by required conditions
CI / build binary | macos x86_64 (push) Blocked by required conditions
CI / smoke test | windows x86_64 (push) Blocked by required conditions
CI / smoke test | windows aarch64 (push) Blocked by required conditions
CI / integration test | conda on ubuntu (push) Blocked by required conditions
CI / integration test | deadsnakes python3.9 on ubuntu (push) Blocked by required conditions
CI / integration test | free-threaded on linux (push) Blocked by required conditions
CI / integration test | github actions (push) Blocked by required conditions
CI / check cache | macos aarch64 (push) Blocked by required conditions
CI / check system | python on debian (push) Blocked by required conditions
CI / check system | python on fedora (push) Blocked by required conditions
CI / check system | python on ubuntu (push) Blocked by required conditions
CI / check system | python on opensuse (push) Blocked by required conditions
CI / check system | python on macos aarch64 (push) Blocked by required conditions
CI / check system | homebrew python on macos aarch64 (push) Blocked by required conditions
CI / check system | python on macos x86-64 (push) Blocked by required conditions
CI / check system | python3.10 on windows x86-64 (push) Blocked by required conditions
CI / check system | python3.10 on windows x86 (push) Blocked by required conditions
CI / check system | python3.13 on windows x86-64 (push) Blocked by required conditions
CI / check system | x86-64 python3.13 on windows aarch64 (push) Blocked by required conditions
CI / check system | windows registry (push) Blocked by required conditions
CI / check system | python3.12 via chocolatey (push) Blocked by required conditions
CI / check system | conda3.8 on linux x86-64 (push) Blocked by required conditions
CI / check system | conda3.11 on windows x86-64 (push) Blocked by required conditions
CI / check system | conda3.8 on windows x86-64 (push) Blocked by required conditions
CI / check system | amazonlinux (push) Blocked by required conditions
CI / cargo test | ubuntu (push) Blocked by required conditions
CI / cargo clippy | ubuntu (push) Blocked by required conditions
CI / cargo clippy | windows (push) Blocked by required conditions
CI / cargo dev generate-all (push) Blocked by required conditions
CI / cargo shear (push) Waiting to run
CI / check windows trampoline | x86_64 (push) Blocked by required conditions
CI / test windows trampoline | i686 (push) Blocked by required conditions
CI / test windows trampoline | x86_64 (push) Blocked by required conditions
CI / typos (push) Waiting to run
CI / mkdocs (push) Waiting to run
CI / build binary | linux libc (push) Blocked by required conditions
CI / Determine changes (push) Waiting to run
CI / lint (push) Waiting to run
CI / cargo test | macos (push) Blocked by required conditions
CI / cargo test | windows (push) Blocked by required conditions
CI / check windows trampoline | aarch64 (push) Blocked by required conditions
CI / check windows trampoline | i686 (push) Blocked by required conditions
CI / build binary | windows x86_64 (push) Blocked by required conditions
CI / build binary | windows aarch64 (push) Blocked by required conditions
CI / cargo build (msrv) (push) Blocked by required conditions
CI / build binary | freebsd (push) Blocked by required conditions
CI / ecosystem test | pydantic/pydantic-core (push) Blocked by required conditions
CI / ecosystem test | prefecthq/prefect (push) Blocked by required conditions
CI / ecosystem test | pallets/flask (push) Blocked by required conditions
CI / smoke test | linux (push) Blocked by required conditions
CI / check system | alpine (push) Blocked by required conditions
CI / smoke test | macos (push) Blocked by required conditions
CI / integration test | free-threaded on windows (push) Blocked by required conditions
CI / integration test | pypy on ubuntu (push) Blocked by required conditions
CI / integration test | pypy on windows (push) Blocked by required conditions
CI / integration test | graalpy on ubuntu (push) Blocked by required conditions
CI / integration test | graalpy on windows (push) Blocked by required conditions
CI / integration test | free-threaded python on github actions (push) Blocked by required conditions
CI / integration test | determine publish changes (push) Blocked by required conditions
CI / integration test | uv publish (push) Blocked by required conditions
CI / integration test | uv_build (push) Blocked by required conditions
CI / check cache | ubuntu (push) Blocked by required conditions
CI / check system | python on rocky linux 8 (push) Blocked by required conditions
CI / check system | python on rocky linux 9 (push) Blocked by required conditions
CI / check system | pypy on ubuntu (push) Blocked by required conditions
CI / check system | pyston (push) Blocked by required conditions
CI / check system | python3.9 via pyenv (push) Blocked by required conditions
CI / check system | python3.13 (push) Blocked by required conditions
CI / check system | conda3.11 on macos aarch64 (push) Blocked by required conditions
CI / check system | conda3.8 on macos aarch64 (push) Blocked by required conditions
CI / check system | conda3.11 on linux x86-64 (push) Blocked by required conditions
CI / check system | embedded python3.10 on windows x86-64 (push) Blocked by required conditions
CI / benchmarks (push) Blocked by required conditions

In #13302, there was an IO error without context. This error seems to be
caused by a symlink error. Switching as symlinking to `fs_err` ensures
these errors will carry context in the future.
This commit is contained in:
konsti 2025-05-05 18:29:27 +02:00 committed by GitHub
parent f557ea3823
commit 3218e364ae
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
9 changed files with 18 additions and 14 deletions

View file

@ -35,4 +35,7 @@ disallowed-methods = [
"std::fs::soft_link", "std::fs::soft_link",
"std::fs::symlink_metadata", "std::fs::symlink_metadata",
"std::fs::write", "std::fs::write",
"std::os::unix::fs::symlink",
"std::os::windows::fs::symlink_dir",
"std::os::windows::fs::symlink_file",
] ]

View file

@ -653,13 +653,13 @@ impl Cache {
let dst = dst.as_ref(); let dst = dst.as_ref();
// Attempt to create the symlink directly. // Attempt to create the symlink directly.
match std::os::unix::fs::symlink(&src, dst) { match fs_err::os::unix::fs::symlink(&src, dst) {
Ok(()) => Ok(()), Ok(()) => Ok(()),
Err(err) if err.kind() == io::ErrorKind::AlreadyExists => { Err(err) if err.kind() == io::ErrorKind::AlreadyExists => {
// Create a symlink, using a temporary file to ensure atomicity. // Create a symlink, using a temporary file to ensure atomicity.
let temp_dir = tempfile::tempdir_in(dst.parent().unwrap())?; let temp_dir = tempfile::tempdir_in(dst.parent().unwrap())?;
let temp_file = temp_dir.path().join("link"); let temp_file = temp_dir.path().join("link");
std::os::unix::fs::symlink(&src, &temp_file)?; fs_err::os::unix::fs::symlink(&src, &temp_file)?;
// Move the symlink into the target location. // Move the symlink into the target location.
fs_err::rename(&temp_file, dst)?; fs_err::rename(&temp_file, dst)?;

View file

@ -121,13 +121,13 @@ pub fn replace_symlink(src: impl AsRef<Path>, dst: impl AsRef<Path>) -> std::io:
#[cfg(unix)] #[cfg(unix)]
pub fn replace_symlink(src: impl AsRef<Path>, dst: impl AsRef<Path>) -> std::io::Result<()> { pub fn replace_symlink(src: impl AsRef<Path>, dst: impl AsRef<Path>) -> std::io::Result<()> {
// Attempt to create the symlink directly. // Attempt to create the symlink directly.
match std::os::unix::fs::symlink(src.as_ref(), dst.as_ref()) { match fs_err::os::unix::fs::symlink(src.as_ref(), dst.as_ref()) {
Ok(()) => Ok(()), Ok(()) => Ok(()),
Err(err) if err.kind() == std::io::ErrorKind::AlreadyExists => { Err(err) if err.kind() == std::io::ErrorKind::AlreadyExists => {
// Create a symlink, using a temporary file to ensure atomicity. // Create a symlink, using a temporary file to ensure atomicity.
let temp_dir = tempfile::tempdir_in(dst.as_ref().parent().unwrap())?; let temp_dir = tempfile::tempdir_in(dst.as_ref().parent().unwrap())?;
let temp_file = temp_dir.path().join("link"); let temp_file = temp_dir.path().join("link");
std::os::unix::fs::symlink(src, &temp_file)?; fs_err::os::unix::fs::symlink(src, &temp_file)?;
// Move the symlink into the target location. // Move the symlink into the target location.
fs_err::rename(&temp_file, dst.as_ref())?; fs_err::rename(&temp_file, dst.as_ref())?;

View file

@ -493,14 +493,14 @@ fn synchronized_copy(from: &Path, to: &Path, locks: &Locks) -> std::io::Result<(
#[cfg(unix)] #[cfg(unix)]
fn create_symlink<P: AsRef<Path>, Q: AsRef<Path>>(original: P, link: Q) -> std::io::Result<()> { fn create_symlink<P: AsRef<Path>, Q: AsRef<Path>>(original: P, link: Q) -> std::io::Result<()> {
std::os::unix::fs::symlink(original, link) fs_err::os::unix::fs::symlink(original, link)
} }
#[cfg(windows)] #[cfg(windows)]
fn create_symlink<P: AsRef<Path>, Q: AsRef<Path>>(original: P, link: Q) -> std::io::Result<()> { fn create_symlink<P: AsRef<Path>, Q: AsRef<Path>>(original: P, link: Q) -> std::io::Result<()> {
if original.as_ref().is_dir() { if original.as_ref().is_dir() {
std::os::windows::fs::symlink_dir(original, link) fs_err::os::windows::fs::symlink_dir(original, link)
} else { } else {
std::os::windows::fs::symlink_file(original, link) fs_err::os::windows::fs::symlink_file(original, link)
} }
} }

View file

@ -761,7 +761,7 @@ impl ManagedPythonDownload {
// to that date do not. // to that date do not.
#[cfg(unix)] #[cfg(unix)]
{ {
match std::os::unix::fs::symlink( match fs_err::os::unix::fs::symlink(
format!("python{}.{}", self.key.major, self.key.minor), format!("python{}.{}", self.key.major, self.key.minor),
extracted.join("bin").join("python"), extracted.join("bin").join("python"),
) { ) {

View file

@ -384,7 +384,7 @@ pub(crate) fn create(
&& interpreter.markers().os_name() == "posix" && interpreter.markers().os_name() == "posix"
&& interpreter.markers().sys_platform() != "darwin" && interpreter.markers().sys_platform() != "darwin"
{ {
match std::os::unix::fs::symlink("lib", location.join("lib64")) { match fs_err::os::unix::fs::symlink("lib", location.join("lib64")) {
Ok(()) => {} Ok(()) => {}
Err(err) if err.kind() == io::ErrorKind::AlreadyExists => {} Err(err) if err.kind() == io::ErrorKind::AlreadyExists => {}
Err(err) => { Err(err) => {

View file

@ -1765,7 +1765,7 @@ fn build_with_symlink() -> Result<()> {
requires = ["hatchling"] requires = ["hatchling"]
build-backend = "hatchling.build" build-backend = "hatchling.build"
"#})?; "#})?;
std::os::unix::fs::symlink( fs_err::os::unix::fs::symlink(
context.temp_dir.child("pyproject.toml.real"), context.temp_dir.child("pyproject.toml.real"),
context.temp_dir.child("pyproject.toml"), context.temp_dir.child("pyproject.toml"),
)?; )?;

View file

@ -3723,7 +3723,7 @@ fn launcher_with_symlink() -> Result<()> {
); );
#[cfg(windows)] #[cfg(windows)]
if let Err(error) = std::os::windows::fs::symlink_file( if let Err(error) = fs_err::os::windows::fs::symlink_file(
context.venv.join("Scripts\\simple_launcher.exe"), context.venv.join("Scripts\\simple_launcher.exe"),
context.temp_dir.join("simple_launcher.exe"), context.temp_dir.join("simple_launcher.exe"),
) { ) {
@ -3736,7 +3736,7 @@ fn launcher_with_symlink() -> Result<()> {
} }
#[cfg(unix)] #[cfg(unix)]
std::os::unix::fs::symlink( fs_err::os::unix::fs::symlink(
context.venv.join("bin/simple_launcher"), context.venv.join("bin/simple_launcher"),
context.temp_dir.join("simple_launcher"), context.temp_dir.join("simple_launcher"),
)?; )?;
@ -8123,7 +8123,7 @@ fn install_relocatable() -> Result<()> {
#[cfg(unix)] #[cfg(unix)]
{ {
let script_symlink_path = context.temp_dir.join("black"); let script_symlink_path = context.temp_dir.join("black");
std::os::unix::fs::symlink(script_path, script_symlink_path.clone())?; fs_err::os::unix::fs::symlink(script_path, script_symlink_path.clone())?;
Command::new(script_symlink_path.as_os_str()) Command::new(script_symlink_path.as_os_str())
.assert() .assert()
.success() .success()

View file

@ -746,7 +746,8 @@ fn python_required_python_major_minor() {
// Symlink it to `python3.11`. // Symlink it to `python3.11`.
fs_err::create_dir_all(context.temp_dir.child("child")).unwrap(); fs_err::create_dir_all(context.temp_dir.child("child")).unwrap();
std::os::unix::fs::symlink(path, context.temp_dir.child("child").join("python3.11")).unwrap(); fs_err::os::unix::fs::symlink(path, context.temp_dir.child("child").join("python3.11"))
.unwrap();
// Find `python3.11`, which is `>=3.11.4`. // Find `python3.11`, which is `>=3.11.4`.
uv_snapshot!(context.filters(), context.python_find().arg(">=3.11.4, <3.12").env(EnvVars::UV_TEST_PYTHON_PATH, context.temp_dir.child("child").path()), @r###" uv_snapshot!(context.filters(), context.python_find().arg(">=3.11.4, <3.12").env(EnvVars::UV_TEST_PYTHON_PATH, context.temp_dir.child("child").path()), @r###"