# test.install_executable

- **Module:** test
- **Package:** libtmux
- **Language:** Rust
- **Kind:** function
- **Source:** https://github.com/libtmux/libtmux-rs/blob/f2bae84b9bf1f69fdb38c38c44476a506f071eb5/crates/libtmux/src/test.rs#L1105
- **Page:** https://libtmux.org/en/rs/latest/reference/test-install_executable/

```
pub fn install_executable(
    path: &Path,
    script: &str
) -> std::io::Result<()>
```

Write `script` to `path` as an executable, and return once it can run.

A test that points [`TestServerBuilder::tmux_executable`] at a wrapper
script races every other test in its binary. A process forked while the
script is open for writing keeps that descriptor until it calls `exec`,
and until then running the script fails with `ETXTBSY`: intermittently,
and only under parallel tests. This stages the script beside `path`, moves
it into place, and runs it until an `exec` succeeds.

`script` must start with a `#!` line. The line inserted after it exits 0
when `LIBTMUX_EXECUTABLE_READY` is set, so the readiness run does none of
the script's work.

# Errors

Returns [`std::io::ErrorKind::InvalidInput`] for a script without a `#!`
line, [`std::io::ErrorKind::TimedOut`] when it still cannot run after a
[`scaled`] five seconds, and any error writing it or running it.

## Examples

```rust
use libtmux::test::{install_executable, unique_name};

let directory = std::env::temp_dir().join(unique_name("install"));
std::fs::create_dir(&directory)?;
let greet = directory.join("greet");
install_executable(&greet, "#!/bin/sh\nprintf 'hello %s' \"$1\"\n")?;

let output = std::process::Command::new(&greet).arg("tmux").output()?;
assert_eq!(output.stdout, b"hello tmux");
```

## Parameters

- `path` (`&Path`)
- `script` (`&str`)
