From 2f6689c3c1476c40a7c722491c1fcd5763e7d55f Mon Sep 17 00:00:00 2001 From: nsfisis Date: Mon, 24 Aug 2026 21:07:36 +0900 Subject: fix(require-command): report an unwritable composer.json The write-back probe discarded the file_put_contents result and returned a hard-coded false, so the comparison against false always held and the error branch was taken for every path is_writable() rejected. Compare the write result instead, matching the PHP original. Co-Authored-By: Claude Opus 5 --- crates/shirabe/src/command/require_command.rs | 9 +-------- 1 file changed, 1 insertion(+), 8 deletions(-) diff --git a/crates/shirabe/src/command/require_command.rs b/crates/shirabe/src/command/require_command.rs index 2dfb140d..4f5a0b15 100644 --- a/crates/shirabe/src/command/require_command.rs +++ b/crates/shirabe/src/command/require_command.rs @@ -31,7 +31,6 @@ use crate::repository::RepositorySet; use crate::signal::SignalSubscription; use crate::util::Filesystem; use crate::util::PackageSorter; -use crate::util::Silencer; use indexmap::IndexMap; use shirabe_php_shim::{ PhpMixed, RuntimeException, array_fill_keys, array_intersect, array_keys, array_map, @@ -856,15 +855,9 @@ impl Command for RequireCommand { // check for writability by writing to the file as is_writable can not be trusted on network-mounts // see https://github.com/composer/composer/issues/8231 and https://bugs.php.net/bug.php?id=68926 - let file_path = file.clone(); let backup_contents = self.composer_backup.borrow().clone(); if !is_writable(&file) - && Silencer::call(|| { - shirabe_php_shim::file_put_contents(&file_path, &backup_contents); - Ok::(false) - }) - .ok() - == Some(false) + && shirabe_php_shim::file_put_contents(&file, &backup_contents).is_none() { let msg = format!("{} is not writable.", file); self.get_io().write_error3(&msg, true, io_interface::NORMAL); -- cgit v1.3.1-4-g156e