Skip to content

Commit

Permalink
fix: use which for package manager binary discovery (#6370)
Browse files Browse the repository at this point in the history
### Description

I forgot that on Windows we need to use `which` to find binaries before
running them. We've run into this before and `which` is a straight
forward fix: #5208

### Testing Instructions

On Windows we now correctly find package manager binaries in the Rust
codepath. Verify it doesn't break non-Windows as well.


Closes TURBO-1586

Co-authored-by: Chris Olszewski <Chris Olszewski>
  • Loading branch information
chris-olszewski authored Nov 6, 2023
1 parent be8573d commit 35bf768
Showing 1 changed file with 9 additions and 1 deletion.
10 changes: 9 additions & 1 deletion crates/turborepo-lib/src/task_graph/visitor.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ use tracing::{debug, error, Span};
use turbopath::AbsoluteSystemPath;
use turborepo_env::{EnvironmentVariableMap, ResolvedEnvMode};
use turborepo_ui::{ColorSelector, OutputClient, OutputSink, OutputWriter, PrefixedUI, UI};
use which::which;

use crate::{
cli::EnvMode,
Expand Down Expand Up @@ -260,7 +261,14 @@ impl<'a> Visitor<'a> {
}
}

let mut cmd = Command::new(package_manager.to_string());
let Ok(package_manager_binary) = which(package_manager.to_string()) else {
manager.stop().await;
tracker.cancel();
callback.send(Err(StopExecution)).ok();
return;
};

let mut cmd = Command::new(package_manager_binary);
cmd.args(["run", task_id.task()]);
cmd.current_dir(workspace_directory.as_path());
cmd.stdout(Stdio::piped());
Expand Down

0 comments on commit 35bf768

Please sign in to comment.