pub fn patch_toolchain(path: PathBuf) -> error::Result<()> {
    let patchelf = {
        let mut path = nix_path("patchelf")?;
        path.push("bin");
        path.push("patchelf");
        ensure!(
            is_executable(&path),
            error::Nix { message: format!("{:?} is not executable", path) }
        );
        path
    };
    let linker = nix_dynamic_linker()?;
    let zlib = {
        let mut path = nix_path("zlib")?;
        path.push("lib");
        ensure!(path.is_dir(), error::Nix { message: format!("{:?} is not directory", path) });
        path
    };
    let rpath = {
        let mut result = OsString::with_capacity(zlib.as_os_str().len());
        // https://github.com/NixOS/patchelf/blob/7ec8edbe094ee13c91dadca191f92b9dfac8c0f9/src/patchelf.cc#L1331-L1332
        result.push("$ORIGIN/../lib:");
        result.push(zlib);
        result
    };

    eprintln!(
        r#"patch options:
  patchelf = {:?}
  linker   = {:?}
  rpath    = {:?}"#,
        patchelf, linker, rpath
    );

    patch_toolchain_with_options(path, patchelf, linker, rpath)
}
/// Patch Rust toolchain by auto-detecting
///
/// # Errors
///
/// * if error occuring while detecting `patchelf`, linker or related
/// libraries
/// * if invalid Rust toolchain base path
/// * if error patching toolchain
Patch Rust toolchain by auto-detecting
Patch Rust toolchain by auto - detecting
pub fn patch_toolchain(path: PathBuf) -> error::Result<()> {
    let patchelf = {
        let mut path = nix_path("patchelf")?;
        path.push("bin");
        path.push("patchelf");
        ensure!(
            is_executable(&path),
            error::Nix { message: format!("{:?} is not executable", path) }
        );
        path
    };
    let linker = nix_dynamic_linker()?;
    let zlib = {
        let mut path = nix_path("zlib")?;
        path.push("lib");
        ensure!(path.is_dir(), error::Nix { message: format!("{:?} is not directory", path) });
        path
    };
    let rpath = {
        let mut result = OsString::with_capacity(zlib.as_os_str().len());
        // https://github.com/NixOS/patchelf/blob/7ec8edbe094ee13c91dadca191f92b9dfac8c0f9/src/patchelf.cc#L1331-L1332
        result.push("$ORIGIN/../lib:");
        result.push(zlib);
        result
    };
    eprintln!(
        r#"patch options:
  patchelf = {:?}
  linker   = {:?}
  rpath    = {:?}"#,
        patchelf, linker, rpath
    );
    patch_toolchain_with_options(path, patchelf, linker, rpath)
}
pub fn patch_toolchain ( path : PathBuf ) -> error :: Result < ( ) > { let patchelf = { let mut path = nix_path ( " " ) ? ; path . push ( " " ) ; path . push ( " " ) ; ensure ! ( is_executable ( path ) error Nix { message format ( " " path ) } ) ; path } ; let linker = nix_dynamic_linker ( ) ? ; let zlib = { let mut path = nix_path ( " " ) ? ; path . push ( " " ) ; ensure ! ( path is_dir ( ) error Nix { message format ( " " path ) } ) ; path } ; let rpath = { let mut result = OsString :: with_capacity ( zlib . as_os_str ( ) . len ( ) ) ; // https://github.com/NixOS/patchelf/blob/7ec8edbe094ee13c91dadca191f92b9dfac8c0f9/src/patchelf.cc#L1331-L1332 result . push ( " " ) ; result . push ( zlib ) ; result } ; eprintln ! ( r#"patch options:
  patchelf = {:?}
  linker   = {:?}
  rpath    = {:?}"# patchelf linker rpath ) ; patch_toolchain_with_options ( path , patchelf , linker , rpath ) }
Patch Rust toolchain by auto-detecting
Patch Rust toolchain by auto - detecting
path
PathBuf
errors
if error occuring while detecting `patchelf`, linker or related
libraries
if invalid Rust toolchain base path
if error patching toolchain
if error occuring while detecting ` patchelf ` linker or related libraries if invalid Rust toolchain base path if error patching toolchain