Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(Turborepo): Be explicit about which binary we failed to find #8050

Merged
merged 1 commit into from Apr 29, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
8 changes: 5 additions & 3 deletions crates/turborepo-repository/src/package_manager/mod.rs
Expand Up @@ -281,8 +281,9 @@ pub enum Error {
MultiplePackageManagers { managers: Vec<String> },
#[error(transparent)]
Semver(#[from] node_semver::SemverError),
#[error(transparent)]
Which(#[from] which::Error),
#[error("{0}: {1}")]
// this will be something like "cannot find binary: <thing we tried to find>"
Which(which::Error, String),
#[error("invalid utf8: {0}")]
Utf8Error(#[from] std::string::FromUtf8Error),
#[error(transparent)]
Expand Down Expand Up @@ -525,7 +526,8 @@ impl PackageManager {
let lockfile_path = self.lockfile_path(root_path);
let contents = match self {
PackageManager::Bun => {
Command::new(which("bun")?)
let binary = "bun";
Command::new(which(binary).map_err(|e| Error::Which(e, binary.to_string()))?)
.arg(lockfile_path.to_string())
.current_dir(root_path.to_string())
.output()?
Expand Down
3 changes: 2 additions & 1 deletion crates/turborepo-repository/src/package_manager/yarn.rs
Expand Up @@ -37,7 +37,8 @@ impl<'a> YarnDetector<'a> {
return Ok(version.clone());
}

let yarn_binary = which("yarn")?;
let binary = "yarn";
let yarn_binary = which(binary).map_err(|e| Error::Which(e, binary.to_string()))?;
let output = Command::new(yarn_binary)
.arg("--version")
.current_dir(self.repo_root)
Expand Down