Skip to content

Commit 1d94106

Browse files
fix: Preserve symlinks when running cargo add
1 parent 26bd6b5 commit 1d94106

File tree

1 file changed

+9
-2
lines changed

1 file changed

+9
-2
lines changed

src/cargo/util/toml_mut/manifest.rs

+9-2
Original file line numberDiff line numberDiff line change
@@ -323,9 +323,16 @@ impl LocalManifest {
323323
};
324324
let new_contents_bytes = raw.as_bytes();
325325

326-
cargo_util::paths::write_atomic(&self.path, new_contents_bytes)
327-
}
326+
// Check if the path is a symlink and follow it if it is
327+
let actual_path = if self.path.is_symlink() {
328+
std::fs::read_link(&self.path)?
329+
} else {
330+
self.path.clone()
331+
};
328332

333+
// Write to the actual target path instead of the symlink
334+
cargo_util::paths::write_atomic(&actual_path, new_contents_bytes)
335+
}
329336
/// Lookup a dependency.
330337
pub fn get_dependency_versions<'s>(
331338
&'s self,

0 commit comments

Comments
 (0)