# Function std::env::current_exe [−] [src]

    pub fn current_exe() -> Result<PathBuf>

Returns the filesystem path to the current executable which is running but with the executable name.

The path returned is not necessarily a "real path" to the executable as there may be intermediate symlinks.

# Errors

Acquiring the path to the current executable is a platform-specific operation that can fail for a good number of reasons. Some errors can include, but not be limited to filesystem operations failing or general syscall failures.

# Examples

fn main() { use std::env; match env::current_exe() { Ok(exe_path) => println!("Path of this executable is: {}", exe_path.display()), Err(e) => println!("failed to get current exe path: {}", e), }; }

    use std::env;

    match env::current_exe() {
        Ok(exe_path) => println!("Path of this executable is: {}",
                                  exe_path.display()),
        Err(e) => println!("failed to get current exe path: {}", e),
    };

# Help

## Keyboard Shortcuts

?
  Show this help dialog
S
  Focus the search field
⇤
  Move up in search results
⇥
  Move down in search results
⏎
  Go to active search result

## Search Tricks

Prefix searches with a type followed by a colon (e.g. `fn:`) to restrict the search to a given type.

Accepted types are: `fn`, `mod`, `struct`, `enum`, `trait`, `type`, `macro`, and `const`.

Search functions by type signature (e.g. `vec -> usize`)