Skip to content

Commit 3f9c869

Browse files
fix(daemon): use correct arg group for deciding daemon config (#9088)
### Description #8728 accidentally disconnected the `--no-daemon` and `--daemon` flags. The config was populated using `args.run_args` which is explicitly set to `None` for all `run` commands [here](https://github.com/vercel/turborepo/blob/main/crates/turborepo-lib/src/cli/mod.rs#L1044). This resulted in the config never getting the flag values. ### Testing Instructions Before ``` [0 olszewski@chriss-mbp] /tmp/turbo-bug $ turbo_dev run build --no-daemon -vv 2>&1 | rg turbod 2024-08-30T16:05:12.441-0400 [DEBUG] turborepo_lib::run::builder: skipping turbod since we appear to be in a non-interactive context [0 olszewski@chriss-mbp] /tmp/turbo-bug $ turbo_dev run build --daemon -vv 2>&1 | rg turbod 2024-08-30T16:05:23.639-0400 [DEBUG] turborepo_lib::run::builder: skipping turbod since we appear to be in a non-interactive context ``` After ``` [1 olszewski@chriss-mbp] /tmp/turbo-bug $ turbo_dev run build --no-daemon -vv 2>&1 | rg turbod 2024-08-30T15:59:27.083-0400 [DEBUG] turborepo_lib::run::builder: skipping turbod since --no-daemon was passed [0 olszewski@chriss-mbp] /tmp/turbo-bug $ turbo_dev run build --daemon -vv 2>&1 | rg turbod 2024-08-30T15:59:34.093-0400 [DEBUG] turborepo_lib::daemon::connector: looking for pid in lockfile: AbsoluteSystemPathBuf("/var/folders/3m/rxkycvgs5jgfvs0k9xcgp6km0000gn/T/turbod/5e203d2ff6cb65bf/turbod.pid") ```
1 parent 2f8ff7b commit 3f9c869

File tree

2 files changed

+14
-3
lines changed

2 files changed

+14
-3
lines changed

crates/turborepo-lib/src/cli/mod.rs

+13-2
Original file line numberDiff line numberDiff line change
@@ -223,7 +223,9 @@ pub struct Args {
223223
#[clap(long, global = true)]
224224
pub dangerously_disable_package_manager_check: bool,
225225
#[clap(flatten, next_help_heading = "Run Arguments")]
226-
pub run_args: Option<RunArgs>,
226+
// DO NOT MAKE THIS VISIBLE
227+
// This is explicitly set to None in `run`
228+
run_args: Option<RunArgs>,
227229
// This should be inside `RunArgs` but clap currently has a bug
228230
// around nested flattened optional args: https://github.com/clap-rs/clap/issues/4697
229231
#[clap(flatten)]
@@ -459,6 +461,15 @@ impl Args {
459461
);
460462
}
461463
}
464+
465+
/// Fetch the run args supplied to the command
466+
pub fn run_args(&self) -> Option<&RunArgs> {
467+
if let Some(Command::Run { run_args, .. }) = &self.command {
468+
Some(run_args)
469+
} else {
470+
self.run_args.as_ref()
471+
}
472+
}
462473
}
463474

464475
/// Defines the subcommands for CLI. NOTE: If we change the commands in Go,
@@ -1041,7 +1052,7 @@ pub async fn run(
10411052
let mut command = if let Some(command) = mem::take(&mut cli_args.command) {
10421053
command
10431054
} else {
1044-
let run_args = cli_args.run_args.take().unwrap_or_default();
1055+
let run_args = cli_args.run_args.clone().unwrap_or_default();
10451056
let execution_args = cli_args
10461057
.execution_args
10471058
// We clone instead of take as take would leave the command base a copy of cli_args

crates/turborepo-lib/src/commands/mod.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -88,7 +88,7 @@ impl CommandBase {
8888
.dangerously_disable_package_manager_check
8989
.then_some(true),
9090
)
91-
.with_daemon(self.args.run_args.as_ref().and_then(|args| args.daemon()))
91+
.with_daemon(self.args.run_args().and_then(|args| args.daemon()))
9292
.with_env_mode(
9393
self.args
9494
.command

0 commit comments

Comments
 (0)