diff options
| author | nsfisis <nsfisis@gmail.com> | 2026-08-24 21:07:36 +0900 |
|---|---|---|
| committer | nsfisis <nsfisis@gmail.com> | 2026-08-24 21:07:36 +0900 |
| commit | 2f6689c3c1476c40a7c722491c1fcd5763e7d55f (patch) | |
| tree | 494a73f17bb388ca640bb83342302ca6ebcd42c5 /crates/shirabe/src/command | |
| parent | 20f9787cda5b846c730cff97a4c7a3777ff3414a (diff) | |
| download | php-shirabe-2f6689c3c1476c40a7c722491c1fcd5763e7d55f.tar.gz php-shirabe-2f6689c3c1476c40a7c722491c1fcd5763e7d55f.tar.zst php-shirabe-2f6689c3c1476c40a7c722491c1fcd5763e7d55f.zip | |
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 <noreply@anthropic.com>
Diffstat (limited to 'crates/shirabe/src/command')
| -rw-r--r-- | crates/shirabe/src/command/require_command.rs | 9 |
1 files changed, 1 insertions, 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::<bool, anyhow::Error>(false) - }) - .ok() - == Some(false) + && shirabe_php_shim::file_put_contents(&file, &backup_contents).is_none() { let msg = format!("<error>{} is not writable.</error>", file); self.get_io().write_error3(&msg, true, io_interface::NORMAL); |
