diff --git a/Cargo.lock b/Cargo.lock index cbe520585..0f35e441d 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -1450,6 +1450,12 @@ dependencies = [ "winapi", ] +[[package]] +name = "fs_extra" +version = "1.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "42703706b716c37f96a77aea830392ad231f44c9e9a67872fa5548707e11b11c" + [[package]] name = "fslock" version = "0.2.1" @@ -3297,6 +3303,7 @@ dependencies = [ "distribution-types", "dunce", "flate2", + "fs_extra", "futures", "http-cache-reqwest", "human_bytes", diff --git a/Cargo.toml b/Cargo.toml index 3e2c69964..eeeefefe4 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -53,6 +53,7 @@ distribution-filename = { git = "https://github.com/astral-sh/uv", rev = "65b17f distribution-types = { git = "https://github.com/astral-sh/uv", rev = "65b17f6e81125064ea04c5cfef685516ab660cf5" } dunce = "1.0.4" flate2 = "1.0.28" +fs_extra = "1.3.0" futures = "0.3.30" http-cache-reqwest = "0.14.0" human_bytes = "0.4.3" diff --git a/src/project/mod.rs b/src/project/mod.rs index ab36fbe56..69a208fcd 100644 --- a/src/project/mod.rs +++ b/src/project/mod.rs @@ -559,23 +559,29 @@ pub fn find_project_manifest() -> Option { }) } -/// Create a symlink from the default pixi directory to the custom target -/// directory +/// Create a symlink from the directory to the custom target directory #[cfg(not(windows))] -fn create_symlink(pixi_dir_name: &Path, default_pixi_dir: &Path) { - if default_pixi_dir.exists() { +fn create_symlink(target_dir: &Path, symlink_dir: &Path) { + if symlink_dir.exists() { tracing::debug!( "Symlink already exists at '{}', skipping creating symlink.", - default_pixi_dir.display() + symlink_dir.display() ); return; } - symlink(pixi_dir_name, default_pixi_dir) + let parent = symlink_dir + .parent() + .expect("symlink dir should have parent"); + fs_extra::dir::create_all(parent, false) + .map_err(|e| tracing::error!("Failed to create directory '{}': {}", parent.display(), e)) + .ok(); + + symlink(target_dir, symlink_dir) .map_err(|e| { tracing::error!( "Failed to create symlink from '{}' to '{}': {}", - pixi_dir_name.display(), - default_pixi_dir.display(), + target_dir.display(), + symlink_dir.display(), e ) })