diff --git a/crates/turborepo-lib/src/shim/mod.rs b/crates/turborepo-lib/src/shim/mod.rs index 3f99f51980ebd..9d4e805ed2b80 100644 --- a/crates/turborepo-lib/src/shim/mod.rs +++ b/crates/turborepo-lib/src/shim/mod.rs @@ -134,8 +134,36 @@ fn run_correct_turbo( debug!("Running command as global turbo"); let should_warn_on_global = env::var(TURBO_GLOBAL_WARNING_DISABLED) .map_or(true, |disable| !matches!(disable.as_str(), "1" | "true")); + + let declared_version = repo_state + .root_package_json + .dependencies + .as_ref() + .and_then(|deps| deps.get("turbo")) + .or_else(|| { + repo_state + .root_package_json + .dev_dependencies + .as_ref() + .and_then(|deps| deps.get("turbo")) + }); + if should_warn_on_global { - warn!("No locally installed `turbo` found. Using version: {version}."); + if let Some(declared_version) = declared_version { + warn!( + "No locally installed `turbo` found in your repository. Using globally \ + installed version ({version}), which can cause unexpected \ + behavior.\n\nInstalling the version in your repository ({declared_version}) \ + before calling `turbo` will result in more predictable behavior across \ + environments." + ); + } else { + warn!( + "No locally installed `turbo` found in your repository. Using globally \ + installed version ({version}). Using a specified version in your repository \ + will result in more predictable behavior." + ); + } } Ok(cli::run(Some(repo_state), subscriber, ui)?) }