aboutsummaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authornsfisis <nsfisis@gmail.com>2026-07-04 18:09:20 +0900
committernsfisis <nsfisis@gmail.com>2026-07-04 18:13:36 +0900
commitdea563685a1da4770c38e1878118636ee7b9b253 (patch)
tree9384d8100f66eb6fbf6828a456153a58398eb240
parentafe51053abd338e50fcc0fee3ba641721058da26 (diff)
downloadphp-shirabe-dea563685a1da4770c38e1878118636ee7b9b253.tar.gz
php-shirabe-dea563685a1da4770c38e1878118636ee7b9b253.tar.zst
php-shirabe-dea563685a1da4770c38e1878118636ee7b9b253.zip
feat(config): use shirabe-branded default home/cache/data dirs
Avoid colliding with an existing Composer installation on the same machine by defaulting COMPOSER_HOME/CACHE_DIR/DATA_DIR paths to shirabe/Shirabe instead of composer/Composer, while keeping the env var names, composer.json/lock, and vendor/composer/ unchanged for ecosystem compatibility.
-rw-r--r--crates/shirabe/src/factory.rs26
-rw-r--r--docs/known-incompatibilities.md23
2 files changed, 36 insertions, 13 deletions
diff --git a/crates/shirabe/src/factory.rs b/crates/shirabe/src/factory.rs
index dcbdf5d..52894b2 100644
--- a/crates/shirabe/src/factory.rs
+++ b/crates/shirabe/src/factory.rs
@@ -116,7 +116,7 @@ impl Factory {
let appdata = Platform::get_env("APPDATA").unwrap_or_default();
return Ok(format!(
- "{}/Composer",
+ "{}/Shirabe",
trim(&strtr(&appdata, "\\", "/"), Some("/"))
));
}
@@ -131,12 +131,12 @@ impl Factory {
xdg_config = format!("{}/.config", user_dir);
}
- dirs.push(format!("{}/composer", xdg_config));
+ dirs.push(format!("{}/shirabe", xdg_config));
}
- dirs.push(format!("{}/.composer", user_dir));
+ dirs.push(format!("{}/.shirabe", user_dir));
- // select first dir which exists of: $XDG_CONFIG_HOME/composer or ~/.composer
+ // select first dir which exists of: $XDG_CONFIG_HOME/shirabe or ~/.shirabe
for dir in &dirs {
let dir_copy = dir.clone();
let exists =
@@ -146,7 +146,7 @@ impl Factory {
}
}
- // if none exists, we default to first defined one (XDG one if system uses it, or ~/.composer otherwise)
+ // if none exists, we default to first defined one (XDG one if system uses it, or ~/.shirabe otherwise)
Ok(dirs[0].clone())
}
@@ -164,7 +164,7 @@ impl Factory {
if Platform::is_windows() {
let mut cache_dir = Platform::get_env("LOCALAPPDATA").unwrap_or_default();
if !cache_dir.is_empty() {
- cache_dir = format!("{}/Composer", cache_dir);
+ cache_dir = format!("{}/Shirabe", cache_dir);
} else {
cache_dir = format!("{}/cache", home);
}
@@ -176,17 +176,17 @@ impl Factory {
if PHP_OS == "Darwin" {
// Migrate existing cache dir in old location if present
if is_dir(format!("{}/cache", home))
- && !is_dir(format!("{}/Library/Caches/composer", user_dir))
+ && !is_dir(format!("{}/Library/Caches/shirabe", user_dir))
{
let from = format!("{}/cache", home);
- let to = format!("{}/Library/Caches/composer", user_dir);
+ let to = format!("{}/Library/Caches/shirabe", user_dir);
let _ = Silencer::call(|| Ok::<bool, anyhow::Error>(rename(&from, &to)));
}
- return Ok(format!("{}/Library/Caches/composer", user_dir));
+ return Ok(format!("{}/Library/Caches/shirabe", user_dir));
}
- if home == format!("{}/.composer", user_dir).as_str() && is_dir(format!("{}/cache", home)) {
+ if home == format!("{}/.shirabe", user_dir).as_str() && is_dir(format!("{}/cache", home)) {
return Ok(format!("{}/cache", home));
}
@@ -198,7 +198,7 @@ impl Factory {
xdg_cache
};
- return Ok(format!("{}/composer", xdg_cache));
+ return Ok(format!("{}/shirabe", xdg_cache));
}
Ok(format!("{}/cache", home))
@@ -215,7 +215,7 @@ impl Factory {
}
let user_dir = Self::get_user_dir()?;
- if home != format!("{}/.composer", user_dir) && Self::use_xdg() {
+ if home != format!("{}/.shirabe", user_dir) && Self::use_xdg() {
let xdg_data = Platform::get_env("XDG_DATA_HOME").unwrap_or_default();
let xdg_data = if xdg_data.is_empty() {
format!("{}/.local/share", user_dir)
@@ -223,7 +223,7 @@ impl Factory {
xdg_data
};
- return Ok(format!("{}/composer", xdg_data));
+ return Ok(format!("{}/shirabe", xdg_data));
}
Ok(home.to_string())
diff --git a/docs/known-incompatibilities.md b/docs/known-incompatibilities.md
index 6f043ca..7b9b685 100644
--- a/docs/known-incompatibilities.md
+++ b/docs/known-incompatibilities.md
@@ -7,3 +7,26 @@ NOTE: This is not an exhaustive list. Shirabe is in early development and there
Error messages, in particular those from PHP built-in functions, are not intended to be mapped exactly.
Plugins or external tools that rely on error messages may break.
+
+
+## Default Home/Cache/Data Directories
+
+To avoid conflicting with an existing Composer installation, Shirabe's default system directories
+use `shirabe`/`Shirabe` instead of `composer`/`Composer`.
+
+| Purpose | OS | Composer default | Shirabe default |
+| --------- | ------------- | ------------------------------- | ------------------------------ |
+| Home dir | Unix, XDG | `$XDG_CONFIG_HOME/composer` | `$XDG_CONFIG_HOME/shirabe` |
+| Home dir | Unix, non-XDG | `$HOME/.composer` | `$HOME/.shirabe` |
+| Home dir | Windows | `%APPDATA%/Composer` | `%APPDATA%/Shirabe` |
+| Cache dir | Unix, XDG | `$XDG_CACHE_HOME/composer` | `$XDG_CACHE_HOME/shirabe` |
+| Cache dir | macOS | `$HOME/Library/Caches/composer` | `$HOME/Library/Caches/shirabe` |
+| Cache dir | Windows | `%LOCALAPPDATA%/Composer` | `%LOCALAPPDATA%/Shirabe` |
+| Data dir | Unix, XDG | `$XDG_DATA_HOME/composer` | `$XDG_DATA_HOME/shirabe` |
+
+The following are intentionally left unchanged for ecosystem compatibility:
+
+* `composer.json` and `composer.lock`
+* `vendor/composer/` directory
+
+TODO: a CLI flag or an environment variable to force Shirabe to use compatible paths.