# Browser Paths





`browser-paths` is a tiny cross‑platform helper crate that locates the executable file paths of Chrome and Edge (stable / beta / dev / canary) on the current machine.
It supports **Linux**, **macOS**, and **Windows**, and returns `Option<PathBuf>` so you can easily integrate it into tooling, CLIs, test runners, or browser automation.
---
## Features
- **Chrome & Edge support**:
- Stable, Beta, Dev, Canary channels
- **Cross‑platform**:
- Linux: uses the `which` crate and distro‑style binary names (e.g. `google-chrome-stable`)
- macOS: resolves `/Applications/*.app/Contents/MacOS/*`
- Windows: searches `LOCALAPPDATA`, `PROGRAMFILES`, `ProgramFiles(x86)` for the standard install locations
- **Simple API**:
- Convenience functions for Chrome and Edge
- Helpers to get "latest" (prefer Canary/Dev) and "stable" (prefer Stable/Beta)
---
## Installation
Add this crate to your `Cargo.toml`:
```toml
[dependencies]
browser-paths = "1.0.1"
```
---
## Usage
All public helpers live in the crate root and return `Option<PathBuf>`.
```rust
use browser_paths::{
get_any_chrome_latest,
get_any_chrome_stable,
get_chrome_path,
get_any_edge_latest,
get_any_edge_stable,
get_edge_path,
};
fn main() {
// Latest available Chrome (Canary > Dev > Beta > Stable)
if let Some(path) = get_any_chrome_latest() {
println!("Latest Chrome found at: {}", path.display());
} else {
println!("No Chrome installation found.");
}
// Stable‑ish Chrome (Stable > Beta > Dev > Canary)
if let Some(path) = get_any_chrome_stable() {
println!("Stable Chrome found at: {}", path.display());
}
// Strictly the stable channel only
if let Some(path) = get_chrome_path() {
println!("Chrome stable (only) at: {}", path.display());
}
// Same helpers exist for Edge
if let Some(path) = get_any_edge_latest() {
println!("Latest Edge found at: {}", path.display());
}
if let Some(path) = get_edge_path() {
println!("Edge stable (only) at: {}", path.display());
}
}
```
### Channel‑specific helpers
If you only care about a specific release channel, you can use:
- Chrome:
- `get_chrome_path()` – Stable
- `get_chrome_beta_path()` – Beta
- `get_chrome_dev_path()` – Dev
- `get_chrome_canary_path()` – Canary
- Edge:
- `get_edge_path()` – Stable
- `get_edge_beta_path()` – Beta
- `get_edge_dev_path()` – Dev
- `get_edge_canary_path()` – Canary
All of these return `Option<PathBuf>`, which will be `None` if that channel is not installed on the current platform.
---
## Platform notes
- **Linux**
- Uses the `which` crate to resolve browser binaries.
- Expected names include:
- Chrome: `google-chrome-stable`, `google-chrome-beta`, `google-chrome-unstable`, `google-chrome-canary`
- Edge: `microsoft-edge-stable`, `microsoft-edge-beta`, `microsoft-edge-dev`, `microsoft-edge-canary`
- **macOS**
- Looks for applications in `/Applications` only, using names like:
- Chrome: `Google Chrome.app`, `Google Chrome Beta.app`, `Google Chrome Dev.app`, `Google Chrome Canary.app`
- Edge: `Microsoft Edge.app`, `Microsoft Edge Beta.app`, `Microsoft Edge Dev.app`, `Microsoft Edge Canary.app`
- **Windows**
- Searches these prefixes:
- `%LOCALAPPDATA%`
- `%PROGRAMFILES%`
- `%ProgramFiles(x86)%`
- And then appends the standard install suffix:
- Chrome: `Google\<Channel>\Application\chrome.exe`
- Edge: `Microsoft\<Channel>\Application\msedge.exe`
If a browser or channel is not installed in the expected path, the corresponding function will simply return `None`.
---
## Testing
This crate includes basic tests that assert the discovered paths exist on the current machine. Because they depend on your local browser setup, you may want to run them only on machines where you expect all channels to be installed (e.g. CI images or a dev machine with all variants).
Run tests with:
```bash
cargo test
```
Tracked manual test coverage:
- **macOS**
- [x] Microsoft Edge
- [x] Google Chrome
- [x] Microsoft Edge Dev
- [x] Google Chrome Dev
- [x] Microsoft Edge Beta
- [x] Google Chrome Beta
- [x] Microsoft Edge Canary
- [x] Google Chrome Canary
- **Ubuntu / Linux**
- [ ] Microsoft Edge
- [ ] Google Chrome
- [ ] Microsoft Edge Dev
- [ ] Google Chrome Dev
- [ ] Microsoft Edge Beta
- [ ] Google Chrome Beta
- [ ] Microsoft Edge Canary
- [ ] Google Chrome Canary
- **Windows**
- [ ] Microsoft Edge
- [ ] Google Chrome
- [ ] Microsoft Edge Dev
- [ ] Google Chrome Dev
- [ ] Microsoft Edge Beta
- [ ] Google Chrome Beta
- [ ] Microsoft Edge Canary
- [ ] Google Chrome Canary
---
## Credits
`browser-paths` has been inspired by several outstanding projects in the community:
- [@edge-paths](https://github.com/shirshak55/edge-paths) - Possible paths or binary names of Edge in the current platform
- [@agent-infra/browser-finder](https://github.com/web-infra-dev/agent-browser-sdk) - find browser in your system
## License
This project is licensed under the **MIT License**.