brson · GitHub

Cargo emits this warning when install this package from source:

$ cargo +nightly install -f
warning: To build the current package use `cargo build`, to install the current package run `cargo install --path .`
  Installing uutils v0.0.1 (file:///home/brian/coreutils)
    Finished release [optimized] target(s) in 1.31s
   Replacing /home/brian/.cargo/bin/uutils

That is

warning: To build the current package use `cargo build`, to install the current package run `cargo install --path .

It's not obvious to me what it is warning me about. Maybe cargo install is deprecated (--help doesn't indicate so).

I suspect, after many minutes of consideration, it's intended to explain to npm users that cargo install is not what they expect, but in this case it confused me (enough to write a bug report).

The 'warning' indicates to me that I'm doing something I should not. This is only the case for npm users who think cargo install will be like npm (unless of course cargo install really is deprecated and/or I really shouldn't be using it and/or there's something malformed in the Cargo.toml).


Here's another way to accomplish the goal of deconfusing npm users:

  • Print all the output, without the warning
  • Afterword print a note (not a warning) saying e.g "run uutils by typing uutils at the command line", and "to uninstall uutils run cargo uninstall in this directory."

I think most noobies would read that, understand that they just installed uutils itself to ~/.cargo/bin. And even they don't understand what they did, they'll hopefully understand that it wasn't what they intended, and the very last sentence gives them an escape hatch.

cargo could even omit those notes after cargo install has been called once, since they're more noise than their worth to most Rust users (the existing warning likewise I think is an unnecessary annoyance to Rust users, even if they understand what it means).

And even still, for those who didn't mean to cargo install, the consequences are not bad (they have bins in ~/.cargo/bin that they didn't expect). Eventually they will figure out that cargo install` is not doing what they expect.

An alternative is to explicitly call out npm users, like 'hey npm users, this doesn't work like you might expect'. But I don't like that much because it's polluting my Rust experience with obviously npm stuff that I don't care about.

I really hope this warning is about the npm/cargo difference, because now I've spent a lot of minutes thinking about it.


Edit, again considering the warning

warning: To build the current package use `cargo build`, to install the current package run `cargo install --path .

It's not worded like a warning to npm users, so maybe I'm off base. In particular, I don't know what the cargo install --path is indicating to an npm user.

I really have no idea what this warning is about!


Also the cargo install --path is missing a closing tick, and is followed by an extra space. The --path might more clearly be --path <PATH>, like in --help.

Read the original on github.com ↗