Skip to content

Commit

Permalink
fix(turbo): infinite recursion bug (vercel#3019)
Browse files Browse the repository at this point in the history
  • Loading branch information
NicholasLYang authored Dec 15, 2022
1 parent 7e56503 commit 81099d3
Showing 1 changed file with 13 additions and 4 deletions.
17 changes: 13 additions & 4 deletions crates/turborepo-lib/src/shim.rs
Original file line number Diff line number Diff line change
Expand Up @@ -215,10 +215,7 @@ impl RepoState {
}
});

let current_turbo_is_local_turbo = local_turbo_path == current_exe()?;
// If the local turbo path doesn't exist or if we are local turbo, then we go
// ahead and run the Go code linked in the current binary.
if current_turbo_is_local_turbo || !local_turbo_path.try_exists()? {
if should_run_current_turbo(&local_turbo_path)? {
cli::run(Some(self))
} else {
let canonical_local_turbo = local_turbo_path.canonicalize()?;
Expand Down Expand Up @@ -281,6 +278,18 @@ impl RepoState {
}
}

/// If the local turbo path doesn't exist or if we are local turbo, then we go
/// ahead and run the Go code linked in the current binary.
fn should_run_current_turbo(local_turbo_path: &Path) -> Result<bool> {
// Note we must check if local_turbo_path exists before we
// canonicalize the path, otherwise we'll get an error.
if !local_turbo_path.exists() {
return Ok(true);
}

Ok(local_turbo_path.canonicalize()? == current_exe()?.canonicalize()?)
}

/// Checks for `TURBO_BINARY_PATH` variable. If it is set,
/// we do not try to find local turbo, we simply run the command as
/// the current binary. This is due to legacy behavior of `TURBO_BINARY_PATH`
Expand Down

0 comments on commit 81099d3

Please sign in to comment.