aboutsummaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
-rw-r--r--crates/shirabe/src/command/require_command.rs48
-rw-r--r--crates/shirabe/src/lib.rs1
2 files changed, 27 insertions, 22 deletions
diff --git a/crates/shirabe/src/command/require_command.rs b/crates/shirabe/src/command/require_command.rs
index 16bc73f0..05f86480 100644
--- a/crates/shirabe/src/command/require_command.rs
+++ b/crates/shirabe/src/command/require_command.rs
@@ -301,32 +301,38 @@ impl Command for RequireCommand {
composer.get_package().get_minimum_stability().to_string()
};
+ // Hoist argument computations into locals so no borrow of `input` is held across the
+ // call: `determine_requirements` may prompt via ConsoleIO, which mutably borrows the
+ // same input RefCell.
+ let packages: Vec<String> = input
+ .borrow()
+ .get_argument("packages")?
+ .as_list()
+ .map(|l| {
+ l.iter()
+ .filter_map(|v| v.as_string().map(|s| s.to_string()))
+ .collect()
+ })
+ .unwrap_or_default();
+ // if there is no update, we need to use the best possible version constraint directly as we cannot rely on the solver to guess the best constraint
+ let no_update = input
+ .borrow()
+ .get_option("no-update")?
+ .as_bool()
+ .unwrap_or(false);
+ let fixed = input
+ .borrow()
+ .get_option("fixed")?
+ .as_bool()
+ .unwrap_or(false);
let requirements_result = self.determine_requirements(
input.clone(),
output.clone(),
- input
- .borrow()
- .get_argument("packages")?
- .as_list()
- .map(|l| {
- l.iter()
- .filter_map(|v| v.as_string().map(|s| s.to_string()))
- .collect()
- })
- .unwrap_or_default(),
+ packages,
Some(&platform_repo),
&preferred_stability,
- // if there is no update, we need to use the best possible version constraint directly as we cannot rely on the solver to guess the best constraint
- input
- .borrow()
- .get_option("no-update")?
- .as_bool()
- .unwrap_or(false),
- input
- .borrow()
- .get_option("fixed")?
- .as_bool()
- .unwrap_or(false),
+ no_update,
+ fixed,
);
let requirements = match requirements_result {
diff --git a/crates/shirabe/src/lib.rs b/crates/shirabe/src/lib.rs
index 2db47fcd..8d0a58bc 100644
--- a/crates/shirabe/src/lib.rs
+++ b/crates/shirabe/src/lib.rs
@@ -196,7 +196,6 @@ mod cli_tests {
run_reinstall => "reinstall",
run_remove => "remove",
run_repository => "repository",
- #[ignore = "currently panics"]
run_require => "require",
run_run_script => "run-script",
run_search => "search",