
Locate installed executables on PATH across environments; supports regex-based searches, enumeration of multiple matches, and configurable system backends for custom environment handling.
This is a Kotlin Multiplatform line-by-line transliteration port of harryfei/which-rs.
Original Project: This port is based on harryfei/which-rs. All design credit and project intent belong to the upstream authors; this repository is a faithful port to Kotlin Multiplatform with no behavioural changes intended.
This is an in-progress port. The goal is feature parity with the upstream Rust crate while providing a native Kotlin Multiplatform API. Every Kotlin file carries a // port-lint: source <path> header naming its upstream Rust counterpart so the AST-distance tool can track provenance.
The text below is reproduced and lightly edited from
https://github.com/harryfei/which-rs.git. It is the upstream project's own description and remains under the upstream authors' authorship; links have been rewritten to absolute upstream URLs so they continue to resolve from this repository.
A Rust equivalent of Unix command "which". Locate installed executable in cross platforms.
This project aims to support WebAssembly with the WASI extension. All wasm32-wasi* targets are officially supported.
If you need to add a conditional dependency on which please refer to the relevant Cargo documentation for platform specific dependencies.
Here's an example of how to conditionally add which. You should tweak this to your needs.
[target.'cfg(not(all(target_family = "wasm", target_os = "unknown")))'.dependencies]
which = "8.0.0"Note that non-WASI environments have no access to the system. Using this in that situation requires disabling the default features of this crate and providing a custom which::sys::Sys implementation to which::WhichConfig.
To find which rustc executable binary is using.
use which::which;
let result = which("rustc").unwrap();
assert_eq!(result, PathBuf::from("/usr/bin/rustc"));After enabling the regex feature, find all Cargo subcommand executables on the path:
use which::which_re;
which_re(Regex::new("^cargo-.*").unwrap()).unwrap()
.for_each(|pth| println!("{}", pth.to_string_lossy()));This crate currently has an MSRV of Rust 1.70. Increasing the MSRV is considered a breaking change and thus requires a major version bump.
We cannot make any guarantees about the MSRV of our dependencies. You may be required to pin one of our dependencies to a lower version in your own Cargo.toml in order to compile with the minimum supported Rust version. Eventually Cargo will handle this automatically. See rust-lang/cargo#9930 for more.
The documentation is available online.
dependencies {
implementation("io.github.kotlinmania:which-kotlin:0.1.3")
}./gradlew build
./gradlew testSee AGENTS.md for translator discipline, port-lint header convention, and Rust -> Kotlin idiom mapping.
This Kotlin port is distributed under the same MIT license as the upstream harryfei/which-rs. See LICENSE (and any sibling LICENSE-* / NOTICE files mirrored from upstream) for the full text.
Original work copyrighted by the which-rs authors.
Kotlin port: Copyright (c) 2026 Sydney Renee and The Solace Project.
Thanks to the harryfei/which-rs maintainers and contributors for the original Rust implementation. This port reproduces their work in Kotlin Multiplatform; bug reports about upstream design or behavior should go to the upstream repository.
This is a Kotlin Multiplatform line-by-line transliteration port of harryfei/which-rs.
Original Project: This port is based on harryfei/which-rs. All design credit and project intent belong to the upstream authors; this repository is a faithful port to Kotlin Multiplatform with no behavioural changes intended.
This is an in-progress port. The goal is feature parity with the upstream Rust crate while providing a native Kotlin Multiplatform API. Every Kotlin file carries a // port-lint: source <path> header naming its upstream Rust counterpart so the AST-distance tool can track provenance.
The text below is reproduced and lightly edited from
https://github.com/harryfei/which-rs.git. It is the upstream project's own description and remains under the upstream authors' authorship; links have been rewritten to absolute upstream URLs so they continue to resolve from this repository.
A Rust equivalent of Unix command "which". Locate installed executable in cross platforms.
This project aims to support WebAssembly with the WASI extension. All wasm32-wasi* targets are officially supported.
If you need to add a conditional dependency on which please refer to the relevant Cargo documentation for platform specific dependencies.
Here's an example of how to conditionally add which. You should tweak this to your needs.
[target.'cfg(not(all(target_family = "wasm", target_os = "unknown")))'.dependencies]
which = "8.0.0"Note that non-WASI environments have no access to the system. Using this in that situation requires disabling the default features of this crate and providing a custom which::sys::Sys implementation to which::WhichConfig.
To find which rustc executable binary is using.
use which::which;
let result = which("rustc").unwrap();
assert_eq!(result, PathBuf::from("/usr/bin/rustc"));After enabling the regex feature, find all Cargo subcommand executables on the path:
use which::which_re;
which_re(Regex::new("^cargo-.*").unwrap()).unwrap()
.for_each(|pth| println!("{}", pth.to_string_lossy()));This crate currently has an MSRV of Rust 1.70. Increasing the MSRV is considered a breaking change and thus requires a major version bump.
We cannot make any guarantees about the MSRV of our dependencies. You may be required to pin one of our dependencies to a lower version in your own Cargo.toml in order to compile with the minimum supported Rust version. Eventually Cargo will handle this automatically. See rust-lang/cargo#9930 for more.
The documentation is available online.
dependencies {
implementation("io.github.kotlinmania:which-kotlin:0.1.3")
}./gradlew build
./gradlew testSee AGENTS.md for translator discipline, port-lint header convention, and Rust -> Kotlin idiom mapping.
This Kotlin port is distributed under the same MIT license as the upstream harryfei/which-rs. See LICENSE (and any sibling LICENSE-* / NOTICE files mirrored from upstream) for the full text.
Original work copyrighted by the which-rs authors.
Kotlin port: Copyright (c) 2026 Sydney Renee and The Solace Project.
Thanks to the harryfei/which-rs maintainers and contributors for the original Rust implementation. This port reproduces their work in Kotlin Multiplatform; bug reports about upstream design or behavior should go to the upstream repository.