From b1ffe7d5537dad5250181868f22edce0d1b78d6f Mon Sep 17 00:00:00 2001 From: Max Kapur Date: Mon, 3 Mar 2025 19:15:02 -0600 Subject: [PATCH] Run `conda clean` after `conda update` if `cleanup = true` (#1047) * Run `conda clean` after `conda upgrade` if `cleanup = true` * Also run `mamba clean` --- src/steps/generic.rs | 30 ++++++++++++++++++++++++++---- 1 file changed, 26 insertions(+), 4 deletions(-) diff --git a/src/steps/generic.rs b/src/steps/generic.rs index 2dae37a6..c9bdbbc0 100644 --- a/src/steps/generic.rs +++ b/src/steps/generic.rs @@ -529,12 +529,23 @@ pub fn run_conda_update(ctx: &ExecutionContext) -> Result<()> { print_separator("Conda"); - let mut command = ctx.run_type().execute(conda); + let mut command = ctx.run_type().execute(&conda); command.args(["update", "--all", "-n", "base"]); if ctx.config().yes(Step::Conda) { command.arg("--yes"); } - command.status_checked() + command.status_checked()?; + + if ctx.config().cleanup() { + let mut command = ctx.run_type().execute(conda); + command.args(["clean", "--all"]); + if ctx.config().yes(Step::Conda) { + command.arg("--yes"); + } + command.status_checked()?; + } + + Ok(()) } pub fn run_pixi_update(ctx: &ExecutionContext) -> Result<()> { @@ -549,12 +560,23 @@ pub fn run_mamba_update(ctx: &ExecutionContext) -> Result<()> { print_separator("Mamba"); - let mut command = ctx.run_type().execute(mamba); + let mut command = ctx.run_type().execute(&mamba); command.args(["update", "--all", "-n", "base"]); if ctx.config().yes(Step::Mamba) { command.arg("--yes"); } - command.status_checked() + command.status_checked()?; + + if ctx.config().cleanup() { + let mut command = ctx.run_type().execute(&mamba); + command.args(["clean", "--all"]); + if ctx.config().yes(Step::Mamba) { + command.arg("--yes"); + } + command.status_checked()?; + } + + Ok(()) } pub fn run_miktex_packages_update(ctx: &ExecutionContext) -> Result<()> {