which-rs

Rust crate that locates executable binaries on PATH, mirroring the Unix which command cross-platform

Library
Cargo
v8.0.5
267stars
MIT License

Repository Health

Pre-computed score based on development activity, maintenance, community, maturity, and trend momentum.How we score it →
58/100Fair
Development Activity48
Maintenance36
Community68
Maturity60
Momentum20

Technical Analysis

AI-assessed by reading the actual repository — architecture, code quality, innovation, and documentation.How we score it →
74/100Good
Architecture78
Code Quality76
Innovation62
Learning Curve80

which-rs is a Rust library that implements the behavior of the Unix which(1) command as a typed, embeddable function rather than a shell-out. Given a binary name, it searches $PATH (and honors PATHEXT on Windows) to return the absolute path of the first matching executable file, correctly handling absolute and relative paths, symlinks, and platform-specific executable-permission checks.

It supports Linux, macOS, Windows, and WASI targets, with an optional regex feature (which_re) for finding every executable on PATH matching a pattern — useful for discovering all cargo-* subcommands, for example. The crate abstracts platform differences behind a Sys trait, so callers needing full control (or running in restricted/sandboxed environments without direct filesystem access) can disable the default real-sys feature and supply a custom system implementation.

What You Get

  • A which() function that resolves an executable name to its absolute path using PATH lookup rules
  • A which_all() iterator returning every matching executable on PATH, not just the first
  • Optional regex-based lookup (which_re) to find all executables matching a pattern, e.g. every installed cargo-* subcommand
  • Cross-platform support for Linux, macOS, Windows (including PATHEXT), and WASI
  • A pluggable Sys trait so the default filesystem-backed implementation can be swapped for sandboxed or test environments

Common Use Cases

  • A build tool or CLI checking whether a required external binary (e.g. git, ffmpeg, rustc) is installed before invoking it
  • A cross-platform Rust application that needs to locate a companion tool without hardcoding OS-specific PATH logic
  • Discovering all installed Cargo subcommands or plugin binaries via the regex feature
  • Test or sandboxed environments that inject a mock Sys implementation to simulate PATH contents without touching the real filesystem

Under The Hood

Architecture - The crate splits responsibilities cleanly across small modules: finder.rs (391 lines) owns the core PATH-walking algorithm and iterator logic, checker.rs verifies a candidate path is actually an executable file (permission bits on Unix, extension matching via sys.rs on Windows), error.rs defines the crate’s Result/Error types, and sys.rs (330 lines) abstracts OS-specific behavior (reading PATH/PATHEXT, permission checks, WASI/Redox variants) behind a Sys trait so the finder logic itself stays platform-agnostic. lib.rs (745 lines, mostly public API and doc examples) exposes which, which_all, which_in, and the regex variants as thin wrappers over Finder. Tech Stack - Pure Rust, 2021 edition, MSRV 1.70. Dependencies are minimal and mostly optional: libc (Unix-only, gated behind the default real-sys feature) for permission checks, regex behind the regex feature, and tracing behind an opt-in feature for diagnostic logging; win_ffi.rs adds a small amount of raw Windows FFI for Windows-specific path resolution. Dev-dependencies are limited to tempfile for filesystem-based tests. Code Quality - The crate ships a real test suite (tests/basic.rs, tests/windows_no_pathext.rs) plus clippy.toml and deny.toml configuration, indicating active lint and dependency-auditing discipline; a RELEASE_STEPS.md and maintained CHANGELOG.md show a deliberate release process across 15 published versions. The Sys trait abstraction is a clean invariant boundary between deterministic PATH-search logic and OS-specific filesystem calls, which also makes the core algorithm independently testable. API Design - The public API is small and predictable: which(name) for the common case, which_all for every match, and _in variants that accept an explicit PATH/cwd override for testing or sandboxing, all documented with runnable doc-examples in lib.rs. Feature flags (regex, tracing, real-sys) are additive and off-by-default where appropriate, keeping the default dependency footprint minimal for the common case of just resolving one binary name.

Used by 10 apps in this directory

Java
34%
Apache 2.0

Enso

Analytics · Data Engineering · Low Code Platforms

7,437

A visual and textual programming platform for data prep and analysis where the node graph and the underlying Enso code are always perfectly in sync, built by an Alteryx co-founder on a GraalVM engine.

View details
70
Repo Health
90
Technical
62
Dependency
Built with
Java34%
TypeScript27%
Scala26%
Updated 1 weeks ago
Rust
69%
Other

GitButler

Developer Tools · Devops · AI Development

21,531

Git, but better — a modern version control client with stacked branches, parallel workflows, unlimited undo, and first-class support for AI-powered development.

View details
89
Repo Health
84
Technical
68
Dependency
Built with
Rust69%
TypeScript18%
Svelte12%
Updated today
Rust
72%
Other

iii

Developer Tools · Devops

18,604

Compose, extend, and observe every backend service in real time using three primitives: Workers, Functions, and Triggers.

View details
86
Repo Health
85
Technical
69
Dependency
Built with
Rust72%
TypeScript17%
Updated yesterday
Rust
46%
MIT

Meetily

Productivity · AI Assistants

29,484

Privacy-first AI meeting assistant that transcribes and summarizes your meetings entirely on your local machine — no cloud, no data leakage.

View details
70
Repo Health
72
Technical
71
Dependency
Built with
Rust46%
TypeScript30%
Updated 2 months ago
Rust
96%
Apache 2.0

codex

AI Code Assistants · Developer Tools

106,760

OpenAI's open-source CLI coding agent that reads, edits, and runs code in your terminal using natural language prompts.

View details
89
Repo Health
80
Technical
77
Dependency
Built with
Rust96%
Updated today
Python
100%
Other

OpenBB

Databases · Analytics · Invoicing Finance

72,027

The AI Workspace for Finance: Connect Data, Run AI Agents, Build Analytics

View details
82
Repo Health
80
Technical
68
Dependency
Built with
Python100%
Updated 2 weeks ago
Rust
77%
AGPL 3.0

Spacedrive

File Storage · Collaboration

38,790

One file manager for all your devices and clouds — powered by a Virtual Distributed File System built in Rust.

View details
60
Repo Health
84
Technical
65
Dependency
Built with
Rust77%
TypeScript20%
Updated 3 weeks ago
Rust
93%
Other

Tabby

AI Code Assistants

33,828

Self-hosted AI coding assistant — run GitHub Copilot-grade code completion on your own hardware with no cloud dependency.

View details
61
Repo Health
78
Technical
63
Dependency
Built with
Rust93%
Updated 1 months ago
Rust
83%
AGPL 3.0

Vaultwarden

Password Manager · Security

65,652

Unofficial Bitwarden-compatible server in Rust — run the full Bitwarden ecosystem on a Raspberry Pi using every official client you already have, without the multi-container overhead.

View details
83
Repo Health
69
Technical
80
Dependency
Built with
Rust83%
Updated 6 days ago

Join founders buildingwith open source

Opinionated takes, migration guides, cost-saving tips, and insights from the open source ecosystem.

Subscribe on Substack
Join 750+ subscribers

Search