Function tauri::api::process::current_binary

source ·
pub fn current_binary(_env: &Env) -> Result<PathBuf>
Expand description

Finds the current running binary’s path.

With exception to any following platform-specific behavior, the path is cached as soon as possible, and then used repeatedly instead of querying for a new path every time this function is called.

Platform-specific behavior

Linux

On Linux, this function will attempt to detect if it’s currently running from a valid AppImage and use that path instead.

macOS

On macOS, this function will return an error if the original path contained any symlinks due to less protection on macOS regarding symlinks. This behavior can be disabled by setting the process-relaunch-dangerous-allow-symlink-macos feature, although it is highly discouraged.

Security

See tauri_utils::platform::current_exe for possible security implications.

Examples

use tauri::{api::process::current_binary, Env, Manager};
let current_binary_path = current_binary(&Env::default()).unwrap();

tauri::Builder::default()
  .setup(|app| {
    let current_binary_path = current_binary(&app.env())?;
    Ok(())
  });