Skip to content

Commit

Permalink
Drop dependency on 'which' crate (#295)
Browse files Browse the repository at this point in the history
std::process::Command determines the path to an executable using the
os-specific PATH variable. As we are only interested in calling the
`erl` executable when building, but not where the executable is placed
within the file system, we can attempt to call it directly.
  • Loading branch information
evnu authored and filmor committed Jan 28, 2020
1 parent 6511e87 commit fe48368
Show file tree
Hide file tree
Showing 2 changed files with 1 addition and 6 deletions.
1 change: 0 additions & 1 deletion rustler/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@ rustler_sys = { path = "../rustler_sys", version = "~2.0" }

[build-dependencies]
lazy_static = "1.4"
which = "3"

[package.metadata.release]

Expand Down
6 changes: 1 addition & 5 deletions rustler/build.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,6 @@ use std::process::Command;
extern crate lazy_static;
use lazy_static::lazy_static;

extern crate which;
use which::which;

lazy_static! {
// keep this sorted by version number
static ref NIF_VERSION: Vec<&'static str> = vec![
Expand All @@ -24,14 +21,13 @@ fn main() {
}

fn get_version_from_erl() -> Option<String> {
let erl = which("erl").ok()?;
let args = vec![
"-noshell",
"-eval",
r#"io:format("~s~n", [erlang:system_info(nif_version)]), init:stop()."#,
];

let version = Command::new(erl).args(&args).output().ok()?.stdout;
let version = Command::new("erl").args(&args).output().ok()?.stdout;

let version = String::from_utf8(version).ok()?;

Expand Down

0 comments on commit fe48368

Please sign in to comment.