Home

Awesome

cargo-local-install

Wraps cargo install for better local, non-conflicting installation

GitHub crates.io docs.rs %23![forbid(unsafe_code)] rust: stable License

Want to script cargo install cargo-web --version 0.6 --root my-project to avoid version conflicts with other projects?<br> Hate having a million copies of cargo-web 0.6.26 and waiting for it to build if you go down that route?<br> cargo-local-install now has your back, and will create symlinks into a global cache of reusable bins:

<h2 name="quickstart">Quickstart</h2>
# no dependencies, builds in < 3 seconds on my machine
cargo install cargo-local-install --no-default-features

# slow first builds that create new exes
cargo local-install --locked cargo-web --version "^0.6" --root project-a # symlinks project-a/bin/cargo-web.exe
cargo local-install --locked cargo-web --version "^0.5" --root project-b # symlinks project-b/bin/cargo-web.exe

# fast cached builds that reuse existing exes
cargo local-install --locked cargo-web --version "^0.6" --root project-c # symlinks project-c/bin/cargo-web.exe
cargo local-install --locked cargo-web --version "^0.6"                  # symlinks bin/cargo-web.exe

# Adds Cargo.toml metadata support, < 30 seconds
cargo install cargo-local-install

Options are broadly similar to cargo install, with a few caveats:

Alternatively, you can specify workspace or package metadata in your Cargo.toml, similar to [dependencies], which will be installed by cargo local-install:

[workspace.metadata.local-install]
cargo-web = "0.6" # == "^0.6" - includes "0.6.26" - locked by default
cargo-web = { version = "0.6", registry = "crates.io", locked = false } # `locked = false` ignores cargo-web's Cargo.lock
cargo-web = { path = "../cargo-web" }
cargo-web = { git = "https://github.com/koute/cargo-web" }
cargo-web = { git = "https://github.com/koute/cargo-web", branch = "master" }
cargo-web = { git = "https://github.com/koute/cargo-web", rev = "a9895bf536e8ac6a0806382886b7be90138f01f3" }

# not (yet?) implemented:
#   features = [...]
#   default-features = false
#   optional = true
<h2 name="what-why">What? Why?</h2>

cargo install is great but suffers a few drawbacks:

cargo local-install attempts to solve these problems:

<h2 name="alternative-sccache">Alternative: sccache</h2>

Some concrete numbers from some local testing with a global .cargo/config rustc-wrapper configured

with sccache configured for local disktimenotes
cargo install cargo-web --root a3m 38scleanish cache, no downloads
cargo install cargo-web --root a~ 1 snoop by cargo install
cargo install cargo-web --root b1m 21smany cache failures based on lurching progress speed?
with local-install (no sccache)timenotes
cargo local-install cargo-web --root c3m 03sclean cache, no downloads of deps
cargo local-install cargo-web --root c~ 1 snoop by cargo install
cargo local-install cargo-web --root d~ 1 strivial cache hit by cargo local-install
<h2 name="license">License</h2>

Licensed under either of

at your option.

<h2 name="contribution">Contribution</h2>

Unless you explicitly state otherwise, any contribution intentionally submitted for inclusion in the work by you, as defined in the Apache-2.0 license, shall be dual licensed as above, without any additional terms or conditions.