9

Suppose I have a successful build:

$ cargo build --release
...
Finished release [optimized] target(s) in 2m 52s

Is there a way to make it available to the system user right away, without uploading to registry?

With Python, for instance, it looks like this:

myutility $ pip install dist/myutility-0.8.2-py3-none-any.whl --user

myutility goes to cache

/home/user/.local/bin/myutility

and is awailable anywhere:

~ $ myutility --help

How am I supposed to go about something like this with Rust (and cargo)?

1
  • 2
    I suggest trying cargo install --path .. Commented Dec 9, 2021 at 16:16

1 Answer 1

18

You can do

$ cargo install --path .

to have cargo compile in release mode and install the crate in the current directory. This makes Cargo install it to ~/.cargo/bin.

4
  • Thanks! I suppose that the release build gets installed no matter what. Is it so? Commented Dec 9, 2021 at 16:55
  • @AlexeyOrlov You can do cargo install --path . --debug to install the debug build.
    – loops
    Commented Dec 9, 2021 at 16:56
  • 3
    Technically it's installed to $CARGO_HOME/bin, but that's just a nitpick to a great short answer.
    – MeetTitan
    Commented Dec 9, 2021 at 23:06
  • 2
    Note that cargo install ignores Cargo.lock by default; to match what cargo build --release would build, use cargo install --path . --locked
    – Nickolay
    Commented Jul 18, 2023 at 4:50

Not the answer you're looking for? Browse other questions tagged or ask your own question.