Closed
Description
Problem
During the integration of cargo-rm
, we found that if a user already got cargo-edit
installed, they will get an error
warning: user-defined alias `rm` is shadowing an external subcommand found at: `/home/user/.cargo/bin/cargo-rm`
This was previously accepted but is being phased out; it will become a hard error in a future release.
For more information, see issue #10049 <https://github.com/rust-lang/cargo/issues/10049>.
which is confusing since rm
is actually not a user-defined alias but a built-in one.
Steps
Create an external subcommand conflicting with the name of a built-in alias
touch $HOME/.cargo/bin/cargo-t
chmod +x $HOME/.cargo/bin/cargo-t
cargo t
and you will see the warning.
Possible Solution(s)
A simple fix I can see is differentiating the warning based on where the alias comes.
Notes
Not directly related but we will in peril when the warning becomes a hard error. The built-in alias such as cargo rm
won't work anymore if user got cargo-edit
installed. This is really a thorny problem because Cargo favors user-defined aliases over built-in (see here). Giving built-in aliases higher priority might fix the issue, though it might break others aliases as well.
Version
cargo 1.64.0 (387270bc7 2022-09-16)
release: 1.64.0
commit-hash: 387270bc7f446d17869c7f208207c73231d6a252
commit-date: 2022-09-16
host: aarch64-apple-darwin
libgit2: 1.4.2 (sys:0.14.2 vendored)
libcurl: 7.79.1 (sys:0.4.55+curl-7.83.1 system ssl:(SecureTransport) LibreSSL/3.3.6)
os: Mac OS 12.6.0 [64-bit]