Skip to content

Commit

Permalink
fix: update find command position
Browse files Browse the repository at this point in the history
  • Loading branch information
fuxiaohei committed Aug 25, 2024
1 parent de44c36 commit 2b6f38d
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 3 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/tests.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ jobs:
run: |
sudo apt install -y binaryen xz-utils
bash ./scripts/land-server-deps.sh
export PATH=$(pwd)/wizer-v7.0.4-x86_64-linux:$PATH
cp -R wizer-v7.0.4-x86_64-linux lib/wizer
- name: Toolchain info
run: |
cargo --version --verbose
Expand Down
9 changes: 7 additions & 2 deletions lib/wasm-gen/src/lib.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
use anyhow::{anyhow, Result};
use std::{
collections::HashMap,
env::current_dir,
io::Write,
path::{Path, PathBuf},
process::{Command, Stdio},
Expand Down Expand Up @@ -64,7 +65,7 @@ fn find_cmd(cmd: &str) -> Result<PathBuf> {
Ok(c) => c,
Err(_) => {
// find xxx binary in current exe directroy ./xxx/xxx
let exe_path = std::env::current_exe()?;
let exe_path = current_dir()?;
let file = exe_path.parent().unwrap().join(format!("{}/{}", cmd, cmd));

#[cfg(target_os = "windows")]
Expand All @@ -74,7 +75,11 @@ fn find_cmd(cmd: &str) -> Result<PathBuf> {
if file.exists() {
return Ok(file);
}
return Err(anyhow!("cannot find '{}' binary", cmd));
return Err(anyhow!(
"cannot find '{}' binary, it should in $PATH or {:?}",
cmd,
file
));
}
};
Ok(c)
Expand Down

0 comments on commit 2b6f38d

Please sign in to comment.