From 44d4b8a566829c137d63c1e2cdef9ae97bb5e88d Mon Sep 17 00:00:00 2001 From: Roey Darwish Dror Date: Tue, 17 Mar 2020 22:49:07 +0200 Subject: [PATCH] Handle a case where asdf is installed using a package manager (fix #374) --- src/steps/os/unix.rs | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/src/steps/os/unix.rs b/src/steps/os/unix.rs index 544cfb65..63d1092a 100644 --- a/src/steps/os/unix.rs +++ b/src/steps/os/unix.rs @@ -1,7 +1,8 @@ #[cfg(target_os = "linux")] use crate::error::SkipStep; +use crate::error::TopgradeError; use crate::execution_context::ExecutionContext; -use crate::executor::{CommandExt, RunType}; +use crate::executor::{CommandExt, ExecutorExitStatus, RunType}; use crate::terminal::{print_separator, print_warning}; use crate::utils::{require, PathExt}; use anyhow::Result; @@ -95,7 +96,13 @@ pub fn run_asdf(run_type: RunType) -> Result<()> { let asdf = require("asdf")?; print_separator("asdf"); - run_type.execute(&asdf).arg("update").check_run()?; + let exit_status = run_type.execute(&asdf).arg("update").spawn()?.wait()?; + + if let ExecutorExitStatus::Wet(e) = exit_status { + if !(e.success() || e.code().map(|c| c == 42).unwrap_or(false)) { + return Err(TopgradeError::ProcessFailed(e).into()); + } + } run_type.execute(&asdf).args(&["plugin", "update", "--all"]).check_run() }