From bc6b3961d122fad4fe509088e0b04741cb6c1f4a Mon Sep 17 00:00:00 2001 From: Chris Olszewski Date: Thu, 6 Jun 2024 09:51:15 -0700 Subject: [PATCH 1/5] feat: warn users when global turbo is being used --- crates/turborepo-lib/src/shim.rs | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/crates/turborepo-lib/src/shim.rs b/crates/turborepo-lib/src/shim.rs index e8d553c48ac26..9bd302f1c7083 100644 --- a/crates/turborepo-lib/src/shim.rs +++ b/crates/turborepo-lib/src/shim.rs @@ -595,7 +595,8 @@ fn run_correct_turbo( spawn_local_turbo(&repo_state, turbo_state, shim_args) } } else { - try_check_for_updates(&shim_args, get_version()); + let version = get_version(); + try_check_for_updates(&shim_args, version); // cli::run checks for this env var, rather than an arg, so that we can support // calling old versions without passing unknown flags. env::set_var( @@ -603,6 +604,7 @@ fn run_correct_turbo( shim_args.invocation_dir.as_path(), ); debug!("Running command as global turbo"); + eprintln!("No local turbo found. Using global turbo version {version}"); Ok(cli::run(Some(repo_state), subscriber, ui)?) } } From b4d4c74aafabefe5f73edb073970be8cbe984be9 Mon Sep 17 00:00:00 2001 From: Chris Olszewski Date: Thu, 6 Jun 2024 10:12:28 -0700 Subject: [PATCH 2/5] chore: add env var to disable global turbo warning --- crates/turborepo-lib/src/shim.rs | 13 ++++++++++++- turborepo-tests/helpers/setup_integration_test.sh | 1 + 2 files changed, 13 insertions(+), 1 deletion(-) diff --git a/crates/turborepo-lib/src/shim.rs b/crates/turborepo-lib/src/shim.rs index 9bd302f1c7083..7c8c6c63c546d 100644 --- a/crates/turborepo-lib/src/shim.rs +++ b/crates/turborepo-lib/src/shim.rs @@ -28,6 +28,8 @@ use turborepo_ui::UI; use crate::{cli, get_version, spawn_child, tracing::TurboSubscriber}; +const TURBO_GLOBAL_WARNING_DISABLED: &str = "TURBO_GLOBAL_WARNING_DISABLED"; + #[derive(Debug, Error, Diagnostic)] #[error("cannot have multiple `--cwd` flags in command")] #[diagnostic(code(turbo::shim::multiple_cwd))] @@ -604,7 +606,16 @@ fn run_correct_turbo( shim_args.invocation_dir.as_path(), ); debug!("Running command as global turbo"); - eprintln!("No local turbo found. Using global turbo version {version}"); + let should_warn_on_global = + env::var(TURBO_GLOBAL_WARNING_DISABLED).map_or(true, |disable| { + match disable.as_str() { + "1" | "true" => false, + _ => true, + } + }); + if should_warn_on_global { + eprintln!("No local turbo found. Using version {version}"); + } Ok(cli::run(Some(repo_state), subscriber, ui)?) } } diff --git a/turborepo-tests/helpers/setup_integration_test.sh b/turborepo-tests/helpers/setup_integration_test.sh index eb09d44ee9c2e..84d682ebd525b 100755 --- a/turborepo-tests/helpers/setup_integration_test.sh +++ b/turborepo-tests/helpers/setup_integration_test.sh @@ -36,6 +36,7 @@ else fi export TURBO_TELEMETRY_MESSAGE_DISABLED=1 +export TURBO_GLOBAL_WARNING_DISABLED=1 export TURBO=${MONOREPO_ROOT_DIR}/target/debug/turbo${EXT} # Undo the set -eo pipefail at the top of this script From cb033cfe0043e5188e29a2eeeef008906b40307b Mon Sep 17 00:00:00 2001 From: Anthony Shew Date: Thu, 6 Jun 2024 12:53:38 -0600 Subject: [PATCH 3/5] Update crates/turborepo-lib/src/shim.rs --- crates/turborepo-lib/src/shim.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/crates/turborepo-lib/src/shim.rs b/crates/turborepo-lib/src/shim.rs index 7c8c6c63c546d..e871bb9952042 100644 --- a/crates/turborepo-lib/src/shim.rs +++ b/crates/turborepo-lib/src/shim.rs @@ -614,7 +614,7 @@ fn run_correct_turbo( } }); if should_warn_on_global { - eprintln!("No local turbo found. Using version {version}"); + eprintln!("No locally installed `turbo` found. Using version: {version}."); } Ok(cli::run(Some(repo_state), subscriber, ui)?) } From 880b67063d32d2711a42affb7b87d85cf4fdb481 Mon Sep 17 00:00:00 2001 From: Chris Olszewski Date: Thu, 6 Jun 2024 13:02:21 -0700 Subject: [PATCH 4/5] chore: fix tests & clippy --- crates/turborepo-lib/src/shim.rs | 9 ++------- turborepo-tests/helpers/setup.sh | 1 + turborepo-tests/integration/tests/prune/resolutions.t | 1 + turborepo-tests/integration/tests/prune/yarn-pnp.t | 1 + 4 files changed, 5 insertions(+), 7 deletions(-) diff --git a/crates/turborepo-lib/src/shim.rs b/crates/turborepo-lib/src/shim.rs index e871bb9952042..ede50dcd26b51 100644 --- a/crates/turborepo-lib/src/shim.rs +++ b/crates/turborepo-lib/src/shim.rs @@ -606,13 +606,8 @@ fn run_correct_turbo( shim_args.invocation_dir.as_path(), ); debug!("Running command as global turbo"); - let should_warn_on_global = - env::var(TURBO_GLOBAL_WARNING_DISABLED).map_or(true, |disable| { - match disable.as_str() { - "1" | "true" => false, - _ => true, - } - }); + let should_warn_on_global = env::var(TURBO_GLOBAL_WARNING_DISABLED) + .map_or(true, |disable| !matches!(disable.as_str(), "1" | "true")); if should_warn_on_global { eprintln!("No locally installed `turbo` found. Using version: {version}."); } diff --git a/turborepo-tests/helpers/setup.sh b/turborepo-tests/helpers/setup.sh index ed10488aa02d1..2f10478ef5379 100755 --- a/turborepo-tests/helpers/setup.sh +++ b/turborepo-tests/helpers/setup.sh @@ -11,4 +11,5 @@ fi # disable the first-run telemetry message export TURBO_TELEMETRY_MESSAGE_DISABLED=1 +export TURBO=${MONOREPO_ROOT_DIR}/target/debug/turbo${EXT} TURBO=${MONOREPO_ROOT_DIR}/target/debug/turbo${EXT} diff --git a/turborepo-tests/integration/tests/prune/resolutions.t b/turborepo-tests/integration/tests/prune/resolutions.t index 3afed5c5dfd91..491cf61f8d65c 100644 --- a/turborepo-tests/integration/tests/prune/resolutions.t +++ b/turborepo-tests/integration/tests/prune/resolutions.t @@ -1,6 +1,7 @@ Setup $ . ${TESTDIR}/../../../helpers/setup.sh $ . ${TESTDIR}/../../../helpers/copy_fixture.sh $(pwd) berry_resolutions ${TESTDIR}/../../fixtures + $ export TURBO_GLOBAL_WARNING_DISABLED=1 Prune a We expect to no longer have the non-resolved is-odd descriptor and diff --git a/turborepo-tests/integration/tests/prune/yarn-pnp.t b/turborepo-tests/integration/tests/prune/yarn-pnp.t index cf2cfa4dadae2..187df1726529c 100644 --- a/turborepo-tests/integration/tests/prune/yarn-pnp.t +++ b/turborepo-tests/integration/tests/prune/yarn-pnp.t @@ -1,6 +1,7 @@ Setup $ . ${TESTDIR}/../../../helpers/setup.sh $ . ${TESTDIR}/../../../helpers/copy_fixture.sh $(pwd) berry_resolutions ${TESTDIR}/../../fixtures + $ export TURBO_GLOBAL_WARNING_DISABLED=1 Remove linker override $ rm .yarnrc.yml Prune the project From bafbd97e08e726d4fcb75ed251fe804a3bd7e3e6 Mon Sep 17 00:00:00 2001 From: Chris Olszewski Date: Thu, 6 Jun 2024 15:33:41 -0700 Subject: [PATCH 5/5] chore: actually disable warning in integration tests --- turborepo-tests/helpers/setup.sh | 2 +- .../integration/tests/lockfile-aware-caching/setup.sh | 1 + 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/turborepo-tests/helpers/setup.sh b/turborepo-tests/helpers/setup.sh index 2f10478ef5379..884c15ec6609a 100755 --- a/turborepo-tests/helpers/setup.sh +++ b/turborepo-tests/helpers/setup.sh @@ -11,5 +11,5 @@ fi # disable the first-run telemetry message export TURBO_TELEMETRY_MESSAGE_DISABLED=1 -export TURBO=${MONOREPO_ROOT_DIR}/target/debug/turbo${EXT} +export TURBO_GLOBAL_WARNING_DISABLED=1 TURBO=${MONOREPO_ROOT_DIR}/target/debug/turbo${EXT} diff --git a/turborepo-tests/integration/tests/lockfile-aware-caching/setup.sh b/turborepo-tests/integration/tests/lockfile-aware-caching/setup.sh index 0fa1c66cd4ac6..4ad5b1ff42638 100755 --- a/turborepo-tests/integration/tests/lockfile-aware-caching/setup.sh +++ b/turborepo-tests/integration/tests/lockfile-aware-caching/setup.sh @@ -1,5 +1,6 @@ #!/bin/bash +export TURBO_GLOBAL_WARNING_DISABLED=1 SCRIPT_DIR=$(dirname ${BASH_SOURCE[0]}) TARGET_DIR=$1 FIXTURE_DIR=$2