-
Notifications
You must be signed in to change notification settings - Fork 2.4k
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
call out that cargo install
!= npm install
#4943
Conversation
r? @matklad (rust_highfive has picked a reviewer for you, use r? to override) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
i would also call out in cargo build
that's similar ISH to npm install
i think this is gonna be very helpful! i know coming from npm i also ran into the muscle memory of wanting to run |
Hm, we also have a large audience of non-npm users, for whom this will be confusing :) Could we instead explain what does “install” actually mean in this context? Perhaps mentioning that it installs the binary into CARGO_HOME would help? |
Install a Rust binary | ||
Install a Rust binary, for example, additional Cargo commands | ||
|
||
(If you're an npm user, please note this is completely unrelated to `npm install`. Please see `cargo build --help`.) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I would think that ‘npm install -g’ is at least partially similar to ‘cargo install’? At least, I use -g to install node utilities for the current user, but I may be missusing this flag :-)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this is a good point, cargo install
is lik
npm install -g`
I added that little bit to the summary because I was reaching for something like this. I think the callout is important, but I also think that the summary line could be improved; maybe this is a good idea.
Wouldn't they see the "if you're an npm user" and just ignore it? |
Probably, but it still requires some mental processing. To put it other way, this logically can be extended to a sizable table “if npm elif pip elif gradle elif bundler...” and this would certainly be questionable :) I guess I am just mildly against the idea of singling out npm specifically, but I don’t have any particularly strong feelings, so let’s defer this to someone else:) Hm, if we add this to Cargo, can we have “this is completely unrelated to ‘cargo install’” in npm’s help message? 😆 |
Having an actual table with equivalences on the crates.io cargo doc could be an option too. This way, it's a useful reference for everyone coming from another language! |
Thanks @steveklabnik! I do sort of share the worry of @matklad though where this may spill over into a very long stream of PRs with "If you're used to X do Y instead"... Would it not solve the intented problem to put this in the online documentation? Or is this intended for the workflow of doing |
In all of my experiences helping people, it's only been
Yes, the intention is for people who don't read the documentation, of which there are many. |
Could this be perhaps rephrased and placed at the end with the rest of the "explain this command" docs? Something like:
|
I think this is a real problem, but I wonder if there might be a better solution, maybe more complex solution. Isn't the issue that people are likely to type When you type
Setting aside scenario 2, for the moment, it seems like rather than editing the usage info which you have to explicitly request, we should print an advisory when you run However, I'm now more worried about scenario 2. Imagine someone creates a little server project, and then tries to build the dependencies with Could we deprecate this behavior of |
Here's a recent example of this kind of confusion happening: https://www.reddit.com/r/rust/comments/7qc82q/rust_mmxviii_but_like_from_a_casual_perspective/dspte37/?context=10 And yeah:
That is, @yoshuawuyts was expecting that It does seem to me like scenario two is very much the situation here. And what's worse is, that means it's gonna be random if it "works" or not, since you may hit a library project instead of one with binaries. (And |
Jeez, the fact that it does build the project makes it seem even worse: you might get the idea that its actually right and keep doing it, further compounding your error. When you move to a lib project, you could get the idea that cargo has two different interfaces for building projects depending on if they're libs or bins. |
An excellent idea! We don’t even need a new flag, because —path . should work. However, at least some users want cargo install to work for local crates: #3697 |
☔ The latest upstream changes (presumably #5152) made this pull request unmergeable. Please resolve the merge conflicts. |
Tagged 2018 for proposed deprecation in #4943 (comment) |
Another instance of this hitting someone on IRC
|
At today's meeting we've came to the conclusion that @withoutboats solution is a way to go! So closing this in favor of #5327 :-) |
Urgh, I must say that, as an expert user, I now dislike the mandatory I guess expert users are somewhat more rare and less important (as they can figure the stuff out) than novices here, so the current solution does seem better overall. But still, not being able to just |
@matklad you could always add a cargo alias to your config for |
I have seen several people assume that
cargo install
isnpm install
. Given that JavaScript programmers are one of our big audiences, I think this deserves an explicit call-out above the fold.