diff --git a/schema/mise.json b/schema/mise.json index b64709cf15..a3ca55dd2f 100644 --- a/schema/mise.json +++ b/schema/mise.json @@ -642,6 +642,13 @@ "description": "Path to the system mise config file. Default is `/etc/mise/config.toml`. This must be an env var.", "type": "string" }, + "task_auto_install": { + "description": "Instead of auto-installing all tools on `mise run`, only install these tools. Set to '[]' to disable the behavior entirely.", + "type": "array", + "items": { + "type": "string" + } + }, "task_disable_paths": { "default": [], "description": "Paths that mise will not look for tasks in.", diff --git a/settings.toml b/settings.toml index 73050c4012..9e8fed37ad 100644 --- a/settings.toml +++ b/settings.toml @@ -842,6 +842,14 @@ type = "Path" optional = true description = "Path to the system mise config file. Default is `/etc/mise/config.toml`. This must be an env var." +[task_auto_install] +env = "MISE_TASK_AUTO_INSTALL" +type = "ListString" +rust_type = "Vec" +parse_env = "list_by_comma" +optional = true +description = "Instead of auto-installing all tools on `mise run`, only install these tools. Set to '[]' to disable the behavior entirely." + [task_disable_paths] env = "MISE_TASK_DISABLE_PATHS" type = "ListPath" @@ -873,6 +881,7 @@ Change output style when executing tasks. This controls the output of `mise run` env = "MISE_TASK_RUN_AUTO_INSTALL" type = "Bool" default = true +hide = true description = "Automatically install missing tools when executing tasks." [task_skip] diff --git a/src/cli/exec.rs b/src/cli/exec.rs index f969724aec..27434edac1 100644 --- a/src/cli/exec.rs +++ b/src/cli/exec.rs @@ -71,6 +71,7 @@ impl Exec { || !console::user_attended_stderr() || *env::__MISE_SHIM, resolve_options: Default::default(), + ..Default::default() }; measure!("install_arg_versions", { ts.install_missing_versions(&opts)? diff --git a/src/cli/install.rs b/src/cli/install.rs index f2f0bdb3a9..241c6d1a27 100644 --- a/src/cli/install.rs +++ b/src/cli/install.rs @@ -80,6 +80,7 @@ impl Install { use_locked_version: true, latest_versions: true, }, + ..Default::default() } } diff --git a/src/cli/run.rs b/src/cli/run.rs index 8958f7180f..108a5590e2 100644 --- a/src/cli/run.rs +++ b/src/cli/run.rs @@ -191,6 +191,7 @@ impl Run { ts.install_missing_versions(&InstallOptions { missing_args_only: !SETTINGS.task_run_auto_install, + missing_tools_auto_install: SETTINGS.task_auto_install.clone(), ..Default::default() })?; let mut env = ts.env_with_path(&Config::get())?; diff --git a/src/toolset/mod.rs b/src/toolset/mod.rs index 2653d78812..e2c945f0c2 100644 --- a/src/toolset/mod.rs +++ b/src/toolset/mod.rs @@ -60,6 +60,7 @@ pub struct InstallOptions { pub raw: bool, /// only install missing tools if passed as arguments pub missing_args_only: bool, + pub missing_tools_auto_install: Option>, pub resolve_options: ResolveOptions, } @@ -70,6 +71,7 @@ impl Default for InstallOptions { raw: SETTINGS.raw, force: false, missing_args_only: true, + missing_tools_auto_install: None, resolve_options: Default::default(), } } @@ -143,6 +145,13 @@ impl Toolset { !opts.missing_args_only || matches!(self.versions[tv.ba()].source, ToolSource::Argument) }) + .filter(|tv| { + if let Some(missing_tools_auto_install) = &opts.missing_tools_auto_install { + missing_tools_auto_install.contains(&tv.ba().short) + } else { + true + } + }) .map(|tv| tv.request) .collect_vec(); let versions = self.install_all_versions(versions, &mpr, opts)?;