Weihang Lo
d7940042bd
Fix cargo add overwriting symlinked Cargo.toml files ( #15281 )
...
### What does this PR try to resolve?
This PR fixes a bug where `cargo add` breaks symlinks to Cargo.toml
files. Currently, when Cargo.toml is a symlink and `cargo add` is used
to add a dependency, the symlink is replaced with a regular file,
breaking the link to the original target file.
This issue was reported in #15241 where a user who relies on symlinked
Cargo.toml files found that `cargo add` breaks their workflow.
Fixes #15241
### How should we test and review this PR?
I've modified `LocalManifest::write()` to check if the path is a
symlink, and if so, follow it to get the actual target path. This
ensures we write to the actual file rather than replacing the symlink.
I've also added a test in `tests/testsuite/cargo_add/symlink.rs` that:
1. Creates a symlinked Cargo.toml file
2. Runs `cargo add` to add a dependency
3. Verifies the symlink is preserved and the dependency is added to the
target file
I've manually tested this fix and confirmed it works correctly.
2025-06-02 10:23:52 +00:00
..
2024-08-22 16:57:06 -05:00
2024-08-22 16:57:06 -05:00
2024-08-22 16:57:06 -05:00
2025-04-01 11:41:30 +02:00
2025-04-01 11:41:30 +02:00
2024-02-22 11:37:03 -06:00
2024-08-22 16:57:06 -05:00
2024-08-22 16:57:06 -05:00
2024-08-22 16:57:06 -05:00
2024-08-22 16:57:06 -05:00
2024-08-30 09:26:56 -05:00
2024-05-27 21:27:03 -05:00
2024-05-27 21:27:03 -05:00
2024-08-22 16:57:06 -05:00
2024-08-22 16:57:06 -05:00
2024-08-22 16:57:06 -05:00
2024-09-06 10:01:49 -07:00
2024-08-22 16:57:06 -05:00
2024-08-22 16:57:06 -05:00
2024-05-27 21:27:03 -05:00
2025-04-01 11:41:30 +02:00
2024-08-22 16:57:06 -05:00
2024-05-27 21:27:03 -05:00
2024-05-27 21:27:03 -05:00
2025-05-01 16:12:36 +02:00
2025-05-01 16:02:15 +02:00
2025-05-01 16:12:36 +02:00
2024-08-22 16:57:06 -05:00
2024-08-22 16:57:06 -05:00
2024-08-22 16:57:06 -05:00
2024-08-22 16:57:06 -05:00
2025-05-01 16:12:36 +02:00
2025-05-01 16:12:36 +02:00
2024-08-22 16:57:06 -05:00
2024-08-22 16:57:06 -05:00
2024-08-22 16:57:06 -05:00
2025-05-01 16:12:36 +02:00
2025-04-30 19:56:31 +02:00
2024-08-22 16:57:06 -05:00
2024-08-22 16:57:06 -05:00
2024-05-27 21:27:03 -05:00
2024-08-22 16:57:06 -05:00
2024-08-22 16:57:06 -05:00
2024-05-27 21:27:03 -05:00
2024-08-22 16:57:06 -05:00
2024-08-22 16:57:06 -05:00
2024-05-27 21:27:03 -05:00
2024-08-22 16:57:06 -05:00
2024-08-22 16:57:06 -05:00
2025-03-20 22:16:27 +08:00
2024-08-22 16:57:06 -05:00
2024-05-27 21:27:03 -05:00
2024-05-27 21:27:03 -05:00
2025-04-01 11:41:30 +02:00
2025-04-01 11:41:30 +02:00
2025-04-01 11:41:30 +02:00
2025-02-09 12:46:36 -08:00
2024-05-27 21:27:03 -05:00
2024-05-27 21:27:03 -05:00
2024-05-27 21:27:03 -05:00
2024-05-27 21:27:03 -05:00
2024-05-27 21:27:03 -05:00
2024-05-27 21:27:03 -05:00
2024-08-22 16:57:06 -05:00
2024-08-30 09:26:56 -05:00
2024-08-30 09:26:56 -05:00
2024-05-27 21:27:03 -05:00
2024-09-24 20:43:02 -04:00
2024-09-24 20:43:02 -04:00
2024-08-22 16:57:06 -05:00
2025-04-01 11:41:30 +02:00
2025-04-27 01:23:51 +02:00
2024-05-27 21:27:03 -05:00
2024-05-27 21:27:03 -05:00
2024-08-30 09:26:56 -05:00
2024-05-27 21:27:03 -05:00
2024-08-30 09:26:56 -05:00
2024-08-22 16:57:06 -05:00
2024-08-22 16:57:06 -05:00
2024-12-05 09:15:17 -06:00
2024-12-05 09:15:17 -06:00
2025-04-01 11:41:30 +02:00
2024-12-05 09:15:17 -06:00
2024-12-05 09:15:17 -06:00
2024-12-05 09:48:21 -06:00
2024-12-05 09:15:17 -06:00
2024-05-27 21:27:03 -05:00
2024-08-22 16:57:06 -05:00
2024-08-30 09:26:56 -05:00
2024-08-30 09:26:56 -05:00
2024-08-22 16:57:06 -05:00
2024-08-22 16:57:06 -05:00
2024-08-22 16:57:06 -05:00
2024-08-22 16:57:06 -05:00
2024-08-22 16:57:06 -05:00
2024-08-22 16:57:06 -05:00
2024-08-22 16:57:06 -05:00
2024-08-22 16:57:06 -05:00
2024-08-30 09:26:56 -05:00
2024-08-30 09:26:56 -05:00
2024-08-22 16:57:06 -05:00
2024-08-22 16:57:06 -05:00
2024-08-22 16:57:06 -05:00
2024-08-22 16:57:06 -05:00
2024-08-22 16:57:06 -05:00
2024-08-22 16:57:06 -05:00
2024-08-22 16:57:06 -05:00
2024-09-06 10:01:49 -07:00
2024-08-22 16:57:06 -05:00
2024-08-30 09:26:56 -05:00
2024-08-22 16:57:06 -05:00
2024-08-22 16:57:06 -05:00
2024-08-22 16:57:06 -05:00
2024-08-30 09:26:56 -05:00
2024-08-30 09:26:56 -05:00
2024-08-30 09:26:56 -05:00
2024-08-22 16:57:06 -05:00
2024-08-22 16:57:06 -05:00
2024-08-30 09:26:56 -05:00
2024-08-22 16:57:06 -05:00
2024-08-22 16:57:06 -05:00
2024-08-22 16:57:06 -05:00
2025-04-01 11:41:30 +02:00
2025-04-01 11:41:30 +02:00
2025-04-01 11:41:30 +02:00
2025-04-01 11:41:30 +02:00
2024-08-22 16:57:06 -05:00
2024-08-22 16:57:06 -05:00
2024-05-27 21:27:03 -05:00
2025-05-03 22:25:12 +05:30
2024-08-22 16:57:06 -05:00
2024-08-22 16:57:06 -05:00
2024-08-22 16:57:06 -05:00
2024-08-22 16:57:06 -05:00
2024-08-30 09:26:56 -05:00
2024-08-30 09:26:56 -05:00
2024-08-22 16:57:06 -05:00
2024-05-27 21:27:03 -05:00
2024-08-22 16:57:06 -05:00
2024-08-22 16:57:06 -05:00
2024-08-22 16:57:06 -05:00
2024-10-04 12:49:28 -05:00
2024-10-04 12:49:28 -05:00
2024-10-04 12:49:28 -05:00
2024-10-04 12:49:28 -05:00
2024-10-04 12:49:28 -05:00
2024-10-04 12:49:28 -05:00
2024-10-04 12:49:28 -05:00
2024-10-04 12:49:28 -05:00
2024-11-26 12:23:48 -06:00
2024-11-26 12:23:48 -06:00
2024-11-26 12:23:48 -06:00
2024-08-30 09:26:56 -05:00
2024-08-22 16:57:06 -05:00
2024-08-22 16:57:06 -05:00
2025-04-30 19:56:31 +02:00
2024-08-22 16:57:06 -05:00
2024-08-22 16:57:06 -05:00
2024-08-22 16:57:06 -05:00
2024-08-22 16:57:06 -05:00
2024-12-05 09:24:46 -06:00
2025-06-02 10:23:52 +00:00
2025-06-02 10:26:42 +05:30