Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

built-in alias is shadowing external subcommand but Cargo warns "user-defined alias is shadowing" #11149

Closed
weihanglo opened this issue Sep 26, 2022 · 0 comments · Fixed by #11170
Labels
A-aliases Area: command aliases A-custom-subcommands Area: custom 3rd party subcommand plugins A-diagnostics Area: Error and warning messages generated by Cargo itself. C-bug Category: bug

Comments

@weihanglo
Copy link
Member

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

  1. touch $HOME/.cargo/bin/cargo-t
  2. chmod +x $HOME/.cargo/bin/cargo-t
  3. 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]
@weihanglo weihanglo added C-bug Category: bug A-aliases Area: command aliases A-custom-subcommands Area: custom 3rd party subcommand plugins A-diagnostics Area: Error and warning messages generated by Cargo itself. labels Sep 26, 2022
@bors bors closed this as completed in b332991 Oct 13, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-aliases Area: command aliases A-custom-subcommands Area: custom 3rd party subcommand plugins A-diagnostics Area: Error and warning messages generated by Cargo itself. C-bug Category: bug
Projects
None yet
1 participant