rust
Summary
Section titled “Summary”zinit-annex-rust installs Rust (via rustup) and Cargo crates locally inside plugin directories, then creates shim scripts in $ZPFX/bin to expose the installed binaries without modifying the global Rust installation.
Details
Section titled “Details”-
Problem it solves: Installing Rust crates globally pollutes the system Cargo/rustup installation and makes per-project or per-tool isolation impossible. This annex scopes Rust and each crate inside the plugin directory.
-
New ices:
rustup— installs Rust (rustup + cargo) locally into the plugin directory; sets$RUSTUP_HOMEand$CARGO_HOMEto point inside the directorycargo'…'— installs one or more crates and optionally creates shims; syntax:Flags:cargo'[binary-name <-] [!][c|N|E|O:]{crate-name} [-> shim-name]; …'!creates a shim in$ZPFX/bin;ccd into plugin dir before running;N/E/Oredirect stdout+stderr / stderr / stdout to/dev/null. Multiple crates separated by;.
-
Shim structure: Each shim sets
$RUSTUP_HOMEand$CARGO_HOMEto the plugin directory, prepends the plugin’sbin/to$PATH, and calls the binary via its embedded absolute path. -
Install:
Terminal window zinit light zdharma-continuum/zinit-annex-rust
Examples
Section titled “Examples”# Install Rust locally + lsd crate + shimzinit ice rustup cargo'!lsd'zinit load zdharma-continuum/null
# exa crate exposed as 'ls'zi ice rustup cargo'!exa -> ls'zi load zdharma-continuum/null
# Multiple crates, no shims (use pick + as"command" to add to $PATH instead)zinit ice rustup cargo'exa;lsd' as"command" pick"bin/(exa|lsd)"zinit load zdharma-continuum/null
# exa with stderr suppressedzinit ice rustup cargo'!E:exa'zinit load zdharma-continuum/null
# Global Rust install in turbo mode, exported for subsequent cargoszi ice \ id-as"rust" \ wait"0" \ lucid \ rustup \ as"command" \ pick"bin/rustc" \ atload='export CARGO_HOME=$PWD RUSTUP_HOME=$PWD/rustup'zi load zdharma-continuum/null
# Subsequent crate that waits for $CARGO_HOME and $RUSTUP_HOME to be setzi for \ wait='[[ -v CARGO_HOME && -v RUSTUP_HOME ]]' \ id-as'rust-exa' \ cargo'!exa' \ zdharma-continuum/nullCaveats / Common Mistakes
Section titled “Caveats / Common Mistakes”- When using a global Rust install (exported via
atload), subsequentcargo''ices must omitrustupand use awaitcondition that checks$CARGO_HOME/$RUSTUP_HOMEare set, or crates will try to install their own Rust. - First-time installation downloads the full Rust toolchain and compiles crates from source — this takes several minutes.
- The
!flag oncargocreates a shim; without it the binary is compiled but not exposed on$PATH.