๐Ÿ“ฆ tauri-apps / fix-path-env-rs

โ˜… 73 stars โ‘‚ 16 forks ๐Ÿ‘ 73 watching โš–๏ธ Apache License 2.0
๐Ÿ“ฅ Clone https://github.com/tauri-apps/fix-path-env-rs.git
HTTPS git clone https://github.com/tauri-apps/fix-path-env-rs.git
SSH git clone git@github.com:tauri-apps/fix-path-env-rs.git
CLI gh repo clone tauri-apps/fix-path-env-rs
Braden Wong Braden Wong feat: add Windows PATH inheritance bug fix (#20) c4c45d5 4 months ago ๐Ÿ“ History
๐Ÿ“‚ dev View all commits โ†’
๐Ÿ“ .changes
๐Ÿ“ .github
๐Ÿ“ examples
๐Ÿ“ src
๐Ÿ“„ .gitignore
๐Ÿ“„ Cargo.toml
๐Ÿ“„ LICENSE
๐Ÿ“„ LICENSE_APACHE-2.0
๐Ÿ“„ LICENSE_MIT
๐Ÿ“„ LICENSE.spdx
๐Ÿ“„ README.md
๐Ÿ“„ renovate.json
๐Ÿ“„ rustfmt.toml
๐Ÿ“„ README.md

fix-path-env-rs

Test

A Rust crate to fix the PATH environment variable on Windows, macOS, and Linux when running a GUI app.

GUI apps have different PATH inheritance issues on different platforms:

  • Windows: std::process::Command sometimes doesn't inherit the parent process's PATH
  • macOS/Linux: GUI apps don't inherit the $PATH from your shell dotfiles (.bashrc, .bash_profile, .zshrc, etc)

Installation

Please note, below in the dependencies you can also lock to a revision/tag in the Cargo.toml.
[dependencies]
fix-path-env = { git = "https://github.com/tauri-apps/fix-path-env-rs" }

Usage

Call fix_path_env::fix() as early as possible in your main function in main.rs file

fn main() {
    let _ = fix_path_env::fix(); // <---- Add this
}

Platform Behavior

Windows

Fixes the PATH inheritance bug in std::process::Command where child processes sometimes can't find executables that are in PATH. This is a known issue where GUI applications on Windows don't properly inherit environment variables from their parent process.

macOS & Linux

Reads your shell configuration (.zshrc, .bash_profile, etc.) to get the PATH that would be available in your terminal, then applies it to the current process. This ensures GUI applications can find commands installed via Homebrew, package managers, or manually added to your shell PATH.

License

MIT / Apache-2.0