Skip to content

Commit 4471f2d

Browse files
feat: warn when no local turbo found (#8356)
### Description Warn a user if they do not have a local turbo install as it might be an incorrect version for their project. ### Testing Instructions ``` [0 olszewski@Chriss-MacBook-Pro] /tmp/foo $ turbo_dev --version 2.0.2-canary.1 [0 olszewski@Chriss-MacBook-Pro] /tmp/foo $ pnpm rm turbo Packages: -2 -- Progress: resolved 1, reused 1, downloaded 0, added 0, done dependencies: - turbo 2.0.2-canary.1 Done in 366ms [0 olszewski@Chriss-MacBook-Pro] /tmp/foo $ turbo_dev --version No local turbo found. Using global turbo version 2.0.2-canary.1 2.0.2-canary.1 ``` Integration tests show that the disabled env flag works. (Otherwise they would all have this warning) --------- Co-authored-by: Anthony Shew <[email protected]>
1 parent 29aeaf0 commit 4471f2d

File tree

6 files changed

+14
-1
lines changed

6 files changed

+14
-1
lines changed

crates/turborepo-lib/src/shim.rs

+9-1
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,8 @@ use turborepo_ui::UI;
2828

2929
use crate::{cli, get_version, spawn_child, tracing::TurboSubscriber};
3030

31+
const TURBO_GLOBAL_WARNING_DISABLED: &str = "TURBO_GLOBAL_WARNING_DISABLED";
32+
3133
#[derive(Debug, Error, Diagnostic)]
3234
#[error("cannot have multiple `--cwd` flags in command")]
3335
#[diagnostic(code(turbo::shim::multiple_cwd))]
@@ -595,14 +597,20 @@ fn run_correct_turbo(
595597
spawn_local_turbo(&repo_state, turbo_state, shim_args)
596598
}
597599
} else {
598-
try_check_for_updates(&shim_args, get_version());
600+
let version = get_version();
601+
try_check_for_updates(&shim_args, version);
599602
// cli::run checks for this env var, rather than an arg, so that we can support
600603
// calling old versions without passing unknown flags.
601604
env::set_var(
602605
cli::INVOCATION_DIR_ENV_VAR,
603606
shim_args.invocation_dir.as_path(),
604607
);
605608
debug!("Running command as global turbo");
609+
let should_warn_on_global = env::var(TURBO_GLOBAL_WARNING_DISABLED)
610+
.map_or(true, |disable| !matches!(disable.as_str(), "1" | "true"));
611+
if should_warn_on_global {
612+
eprintln!("No locally installed `turbo` found. Using version: {version}.");
613+
}
606614
Ok(cli::run(Some(repo_state), subscriber, ui)?)
607615
}
608616
}

turborepo-tests/helpers/setup.sh

+1
Original file line numberDiff line numberDiff line change
@@ -11,4 +11,5 @@ fi
1111

1212
# disable the first-run telemetry message
1313
export TURBO_TELEMETRY_MESSAGE_DISABLED=1
14+
export TURBO_GLOBAL_WARNING_DISABLED=1
1415
TURBO=${MONOREPO_ROOT_DIR}/target/debug/turbo${EXT}

turborepo-tests/helpers/setup_integration_test.sh

+1
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,7 @@ else
3636
fi
3737

3838
export TURBO_TELEMETRY_MESSAGE_DISABLED=1
39+
export TURBO_GLOBAL_WARNING_DISABLED=1
3940
export TURBO=${MONOREPO_ROOT_DIR}/target/debug/turbo${EXT}
4041

4142
# Undo the set -eo pipefail at the top of this script

turborepo-tests/integration/tests/lockfile-aware-caching/setup.sh

+1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
#!/bin/bash
22

3+
export TURBO_GLOBAL_WARNING_DISABLED=1
34
SCRIPT_DIR=$(dirname ${BASH_SOURCE[0]})
45
TARGET_DIR=$1
56
FIXTURE_DIR=$2

turborepo-tests/integration/tests/prune/resolutions.t

+1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
Setup
22
$ . ${TESTDIR}/../../../helpers/setup.sh
33
$ . ${TESTDIR}/../../../helpers/copy_fixture.sh $(pwd) berry_resolutions ${TESTDIR}/../../fixtures
4+
$ export TURBO_GLOBAL_WARNING_DISABLED=1
45

56
Prune a
67
We expect to no longer have the non-resolved is-odd descriptor and

turborepo-tests/integration/tests/prune/yarn-pnp.t

+1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
Setup
22
$ . ${TESTDIR}/../../../helpers/setup.sh
33
$ . ${TESTDIR}/../../../helpers/copy_fixture.sh $(pwd) berry_resolutions ${TESTDIR}/../../fixtures
4+
$ export TURBO_GLOBAL_WARNING_DISABLED=1
45
Remove linker override
56
$ rm .yarnrc.yml
67
Prune the project

0 commit comments

Comments
 (0)