From 3bddf91f8fe386cc9d908ed498ea0b3235790904 Mon Sep 17 00:00:00 2001 From: nsfisis Date: Sun, 22 Feb 2026 15:33:18 +0900 Subject: fix(platform): detect PHP version from runtime instead of hardcoding 8.1 PlatformConfig::new() was hardcoded to PHP 8.1 with a fixed extension list, causing resolution failures for packages requiring newer PHP (e.g. Laravel 12 requires >=8.2). Now calls detect_platform() to discover the actual PHP version, extensions and capabilities. Also adds a mutex to composer_home_dir tests to prevent env-var races. Co-Authored-By: Claude Opus 4.6 --- crates/mozart/src/commands/global.rs | 19 ++++++++++++------- 1 file changed, 12 insertions(+), 7 deletions(-) (limited to 'crates/mozart/src/commands/global.rs') diff --git a/crates/mozart/src/commands/global.rs b/crates/mozart/src/commands/global.rs index a646f7a..97d56d2 100644 --- a/crates/mozart/src/commands/global.rs +++ b/crates/mozart/src/commands/global.rs @@ -121,38 +121,43 @@ mod tests { // ── composer_home_dir tests ─────────────────────────────────────────────── + /// Guards env-var mutations so the three composer_home_dir tests + /// cannot race each other when `cargo test` runs them in parallel. + static ENV_MUTEX: std::sync::Mutex<()> = std::sync::Mutex::new(()); + #[test] fn test_composer_home_dir_from_env() { - // SAFETY: test-only; single-threaded env mutation + let _lock = ENV_MUTEX.lock().unwrap(); + // SAFETY: test-only; protected by ENV_MUTEX unsafe { std::env::set_var("COMPOSER_HOME", "/tmp/test-composer-home"); } let result = composer_home_dir().unwrap(); - assert_eq!(result, PathBuf::from("/tmp/test-composer-home")); - // SAFETY: cleanup unsafe { std::env::remove_var("COMPOSER_HOME"); } + assert_eq!(result, PathBuf::from("/tmp/test-composer-home")); } #[test] fn test_composer_home_dir_xdg() { - // SAFETY: test-only; single-threaded env mutation + let _lock = ENV_MUTEX.lock().unwrap(); + // SAFETY: test-only; protected by ENV_MUTEX unsafe { std::env::remove_var("COMPOSER_HOME"); std::env::set_var("XDG_CONFIG_HOME", "/tmp/test-xdg-config"); } let result = composer_home_dir().unwrap(); - assert_eq!(result, PathBuf::from("/tmp/test-xdg-config/composer")); - // SAFETY: cleanup unsafe { std::env::remove_var("XDG_CONFIG_HOME"); } + assert_eq!(result, PathBuf::from("/tmp/test-xdg-config/composer")); } #[test] fn test_composer_home_dir_default() { - // SAFETY: test-only; single-threaded env mutation + let _lock = ENV_MUTEX.lock().unwrap(); + // SAFETY: test-only; protected by ENV_MUTEX unsafe { std::env::remove_var("COMPOSER_HOME"); std::env::remove_var("XDG_CONFIG_HOME"); -- cgit v1.3.1