opener
Open any file or link in the system default program from Rust, on every major platform.
Repository Health
Technical Analysis
Opener is a small, focused Rust crate that opens a file or URL with whatever program the operating system has configured as the default handler. A single open() call works uniformly across Windows, macOS, Linux, and Windows Subsystem for Linux, hiding the per-platform launch mechanics behind one tiny, dependency-light API.
Beyond plain opening, it provides open_browser() for honoring the $BROWSER environment variable and an optional reveal() function that highlights a file inside the system file manager. It has been battle-tested across the ecosystem, with tens of millions of downloads on crates.io.
What You Get
- A single
open(path)function that resolves and launches the system default program for a file or URL - An
open_browser(path)variant that respects the$BROWSERenvironment variable, ideal for CLIs that want to open documentation or auth pages - An optional
reveal(path)function (behind therevealfeature) that highlights a file inside the platform file manager - Cross-platform coverage for Windows, macOS, Linux, and WSL with automatic WSL detection and path translation
- A structured
OpenErrortype that surfaces spawn failures and non-zero exit statuses with captured stderr
Common Use Cases
- Opening a generated report, log file, or exported document in the user’s default viewer from a desktop or CLI app
- Launching a URL such as an OAuth consent screen or documentation page in the user’s browser
- Revealing a downloaded or produced file in Finder, Explorer, or a Linux file manager so the user can act on it
Under The Hood
Architecture
The crate is organized around a compile-time platform-dispatch pattern in opener/src/lib.rs: cfg attributes alias a sys module to one of macos.rs, windows.rs, or linux_and_more.rs, and the public open/open_browser/reveal functions delegate to it. On Windows (windows.rs) it calls the ShellExecuteW Win32 API directly, retrying with a normalized path on failure; on macOS (macos.rs) it spawns the system open command; on Linux and other Unix (linux_and_more.rs) it detects WSL (via /proc/version and /proc/sys/kernel/osrelease, guarded against Docker false positives), preferring wslview, then a system xdg-open, and finally an xdg-open script embedded with include_bytes! and piped through sh. All child processes flow through a shared wait_child helper that captures stderr into the typed OpenError.
Tech Stack
Written in 100% Rust (edition 2021) as a Cargo workspace with the opener library and a small opener-bin CLI. Dependencies are minimal and platform-gated: windows-sys and normpath on Windows; bstr on Linux, plus optional zbus and url (behind the reveal feature) for the freedesktop D-Bus file-manager interface. The library has no dependencies at all on macOS, leaning entirely on the standard library’s std::process::Command.
Code Quality
The code is idiomatic and disciplined — every crate enables rust_2018_idioms, missing_debug_implementations, and related lints via #![warn(...)], and error handling is thorough: fallible operations map into a #[non_exhaustive] OpenError enum with Io, Spawn, and ExitStatus variants that implement Display and Error with proper source chaining. The notable gap is the absence of an automated test suite; the repository ships no #[test] functions, so correctness rests on manual verification and downstream usage across its large install base.
API Design
The public surface is deliberately tiny and hard to misuse: open, open_browser, and reveal all accept AsRef<OsStr>/AsRef<Path>, so callers pass strings or paths interchangeably with zero boilerplate. Documentation is strong — thorough rustdoc comments spell out platform behavior and the meaning of an Ok(()) result, and published docs live on docs.rs. The result is a get-started-in-one-line experience that is a good fit for both libraries and end-user tools.
Used by 3 apps in this directory
Fyrox
Game Development
A production-ready 2D/3D game engine written in Rust with a built-in scene editor, physics, and hot-reloading game scripts
GitButler
Developer Tools · Devops · AI Development
Git, but better — a modern version control client with stacked branches, parallel workflows, unlimited undo, and first-class support for AI-powered development.
World Monitor
Monitoring · Analytics
Real-time global intelligence dashboard that fuses AI-synthesized news, geopolitical risk scoring, and infrastructure tracking into one open-source situational awareness platform.