Plenty of good command-line tools are written in Rust: ripgrep, fd, hyperfine and just, among others. Installing them usually means installing rustup first, then running cargo install. pnpm 12.25 adds a shortcut. pnx crate:<name> downloads a crate, builds it with a Rust toolchain pnpm manages itself, and runs it. pnpm add -g crate:<name> keeps it on your PATH.
In this guide you'll run ripgrep once without installing it, install it globally, pin and upgrade it, and remove it again. You don't need rustup or ~/.cargo at any point.
What you need
- pnpm 12.25.0 or later. Check with
pnpm --version. If you're on an older release, see the pnpm installation docs. - A C linker. Rust uses the system linker to produce the final binary. On macOS, run
xcode-select --installif you don't have the Command Line Tools. On Linux, install GCC or Clang. The Rust book covers this.
pnpm --version12.25.11. Run a tool once with pnx
pnx is pnpm's npx. With a crate: prefix it fetches the crate from crates.io instead of npm:
pnx crate:ripgrep --versionThe first run does three things. It installs a stable Rust toolchain into the pnpm store, downloads ripgrep and its dependencies, and compiles a release build. Here is the output, with the progress lines and 38 Compiling lines removed:
Installing Rust 1.100.1 (aarch64-apple-darwin)
warning: [email protected]: output from `git rev-parse` is empty, so skipping embedding of commit hash
Finished `release` profile [optimized + debuginfo] target(s) in 48.93s
ripgrep 16.0.0
features:-pcre2
simd(compile):+NEON
simd(runtime):+NEON
PCRE2 is not available in this build of ripgrep.
Done in 1m 0.2s using pnpm v12.25.1That took a minute on an Apple silicon Mac. The compiled binary is kept in pnpm's dlx cache, so running the same command again takes about a second:
ripgrep 16.0.0
features:-pcre2
simd(compile):+NEON
simd(runtime):+NEON
PCRE2 is not available in this build of ripgrep.
Done in 1.3s using pnpm v12.25.1pnpm builds with the crate's own Cargo.lock, the same as cargo install --locked. You get the dependency versions the authors tested, not whatever is newest today. The git rev-parse warning is harmless. It means the crate was built from a published archive, not a git checkout, so there's no commit hash to embed.
2. Pick the version and the executable
Versions follow the same rules as cargo install:
| Specifier | Runs |
|---|---|
crate:ripgrep | The newest stable release |
crate:ripgrep@14 | The newest release that matches ^14 |
crate:[email protected] | Exactly 14.1.1 |
The ripgrep crate's executable is called rg, not ripgrep. pnx runs the executable named after the crate, or the only one the crate has. When neither works, or you want to pass real arguments, name the crate with --package and the command after it:
pnx --package=crate:ripgrep@14 rg TODO srcsrc/index.ts:// TODO: add tests
src/math.ts: // TODO: handle NaN
Done in 416ms using pnpm v12.25.1fd is a good example of the "only executable" rule. The crate is fd-find and the binary is fd, but it's the crate's only executable, so this works without --package:
pnx crate:fd-find --versionwarning: stripping debug info with `rust-objcopy` failed: signal: 6 (SIGABRT)
|
= note: dyld[65014]: Library not loaded: @rpath/libLLVM.dylib
...
Finished `release` profile [optimized] target(s) in 1m 15s
fd 10.5.2
Done in 1m 20.2s using pnpm v12.25.13. Install it globally
For a tool you use every day, install it so it's always on your PATH:
pnpm add -g crate:ripgrep@14Installed crate:ripgrep 14.1.1 globally
Done in 251ms using pnpm v12.25.1That finished in a quarter of a second because the earlier pnx run had already built 14.1.1. Otherwise it compiles here, just like the first pnx run.
The executable goes into pnpm's global bin directory, $PNPM_HOME/bin. pnpm setup adds that directory to your shell's PATH if it isn't there yet:
rg --version | head -1
pnpm list -gripgrep 14.1.1
...
│ dependencies:
└── crate:[email protected]pnpm lists the crate with its crate: prefix, next to any global npm packages. If the global bin directory already has a command with the same name from another package, pnpm stops with ERR_PNPM_GLOBAL_BIN_CONFLICT instead of overwriting it. The global packages docs describe the rule.
4. Update within a range, or jump to the latest
The version you add with is remembered. A plain update stays inside it:
pnpm update -g crate:ripgrepcrate:ripgrep is up to date at 14.1.1
Done in 262ms using pnpm v12.25.1ripgrep 16.0.0 came out on 22 November 2026, but @14 keeps you on 14.x. That's useful when a major release changes flags your scripts rely on. Pass --latest to move to the newest stable release:
pnpm update -g crate:ripgrep --latestwarning: [email protected]: output from `git rev-parse` is empty, so skipping embedding of commit hash
Finished `release` profile [optimized + debuginfo] target(s) in 51.39s
Updated crate:ripgrep from 14.1.1 to 16.0.0
Done in 55.3s using pnpm v12.25.1rg --version now prints ripgrep 16.0.0. Note that pnpm outdated -g doesn't check crates yet, so it won't tell you when a new release is out.
5. Remove it
pnpm remove -g crate:ripgrepRemoved crate:ripgrep
Done in 5ms using pnpm v12.25.1rg is gone from your PATH. The Rust toolchain stays in the store for the next crate.
Where the files go
Everything lives under pnpm's own directories:
- The toolchain is in the store under
rust/. It took about 450 MB on macOS. - Built executables are in the dlx cache until
dlxCacheMaxAgeexpires, and global ones are linked into$PNPM_HOME/bin. - Nothing is written to
~/.rustupor~/.cargo. If you already use rustup, the two don't interfere.
pnpm checks the toolchain download against the Rust release signing key. The Cargo page of the pnpm docs has the details.
Trade-offs and when not to use it
- You run the crate's code at build time. Build scripts and procedural macros of the crate and every dependency run on your machine, exactly as with
cargo install. Naming the crate is your consent, and--allow-builddoesn't apply. IfignoreScriptsis on, pnpm refuses to build crates at all. - Every install is a compile. Expect about a minute per tool, and longer on slow CI runners. If a project ships prebuilt binaries, cargo-binstall or your OS package manager is faster.
- 450 MB for the toolchain. That's fine on a laptop and wasteful in a short-lived container that only needs one tool.
- If you already use rustup,
cargo install --locked ripgrepdoes the same job. The pnpm route is most useful on machines where you don't want a full Rust setup: JavaScript-only laptops, dev containers, or a team that already standardises on pnpm. - It's experimental. The pnpm docs mark multi-ecosystem support as experimental, so settings and layout may change.
Some Cargo tools, such as cargo-dylint, call rustup themselves to get a nightly toolchain. For those, pnpm can install a private rustup alongside the crate with pnpm add -g crate:cargo-dylint,rustup. See Running a crate with rustup.
Next steps
- Read the
pnxreference for--package, Package URL specifiers likepkg:cargo/[email protected], and theruntimeOnFailsetting, which uses thecargoon yourPATHinstead. - See the global packages docs for how crates sit next to global npm packages.
- Check the pnpm 12.25.0 release notes for the other additions, such as
pnpm pack <spec>and dotted keys inpnpm config set. - Try it with the tools mentioned here: ripgrep and fd.