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: warn when no local turbo found #8356

Merged
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.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 9 additions & 1 deletion crates/turborepo-lib/src/shim.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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))]
Expand Down Expand Up @@ -595,14 +597,20 @@ 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(
cli::INVOCATION_DIR_ENV_VAR,
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| !matches!(disable.as_str(), "1" | "true"));
if should_warn_on_global {
eprintln!("No locally installed `turbo` found. Using version: {version}.");
}
Ok(cli::run(Some(repo_state), subscriber, ui)?)
}
}
Expand Down
1 change: 1 addition & 0 deletions turborepo-tests/helpers/setup.sh
Original file line number Diff line number Diff line change
Expand Up @@ -11,4 +11,5 @@ fi

# disable the first-run telemetry message
export TURBO_TELEMETRY_MESSAGE_DISABLED=1
export TURBO_GLOBAL_WARNING_DISABLED=1
TURBO=${MONOREPO_ROOT_DIR}/target/debug/turbo${EXT}
1 change: 1 addition & 0 deletions turborepo-tests/helpers/setup_integration_test.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
#!/bin/bash

export TURBO_GLOBAL_WARNING_DISABLED=1
SCRIPT_DIR=$(dirname ${BASH_SOURCE[0]})
TARGET_DIR=$1
FIXTURE_DIR=$2
Expand Down
1 change: 1 addition & 0 deletions turborepo-tests/integration/tests/prune/resolutions.t
Original file line number Diff line number Diff line change
@@ -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
Expand Down
1 change: 1 addition & 0 deletions turborepo-tests/integration/tests/prune/yarn-pnp.t
Original file line number Diff line number Diff line change
@@ -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
Expand Down
Loading