Skip to content

Commit

Permalink
fix: Preserve symlinks when running cargo add
Browse files Browse the repository at this point in the history
When Cargo.toml is a symlink, cargo add was overwriting it with a regular
file. This change follows the symlink and writes to the target file instead,
preserving the symlink structure.

Fixes rust-lang#15241
  • Loading branch information
RaghavenderSingh committed Mar 9, 2025
1 parent b5147ac commit 4619cd8
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions tests/testsuite/cargo_add/symlink.rs
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,6 @@ fn symlink_case() {

project.cargo("add test-dep").run();

// The bug: symlink is replaced by a regular file
assert!(!project.root().join("Cargo.toml").is_symlink());
// Fix verified: symlink is preserved
assert!(project.root().join("Cargo.toml").is_symlink());
}

0 comments on commit 4619cd8

Please sign in to comment.