Some(path.into_os_string().into_string().expect("Invalid Unicode in path"))
}else{
None
}
}else{
None
}
};
final_path.ok_or(
// This error message may also be caused by $PATH or $CARGO/$RUSTC/etc not being set correctly
// for VSCode, even if they are set correctly in a terminal.
// On macOS in particular, launching VSCode from terminal with `code <dirname>` causes VSCode
// to inherit environment variables including $PATH, $CARGO, $RUSTC, etc from that terminal;
// but launching VSCode from Dock does not inherit environment variables from a terminal.
// For more discussion, see #3118.
Error::msg(format!("Failed to find `{}` executable. Make sure `{}` is in `$PATH`, or set `${}` to point to a valid executable.",executable_name,executable_name,env_var))
)
}
}
/// Does the given `Path` point to a usable executable?
///
/// (assumes the executable takes a `--version` switch and writes to stdout,
/// which is true for `cargo`, `rustc`, and `rustup`)