-
-
Notifications
You must be signed in to change notification settings - Fork 531
Open
Labels
bugThe issue in the code or project, which should be addressed.The issue in the code or project, which should be addressed.
Description
Description
setup/cli-install.php corrupts Windows file paths during the path normalization step, making CLI installation impossible on Windows.
Steps to Reproduce
- Clone MODX 3.x on Windows (e.g. via Laragon)
- Run
php setup/cli-install.phpwith all required parameters - Installation fails with pre-install check errors:
Pre-Install Tests Failed! Errors:
context_web_exists: Failed! - context_mgr_exists: Failed! - context_connectors_exists: Failed! -
context_web_writable: Failed! - context_mgr_writable: Failed! - context_connectors_writable: Failed! -
Root Cause
The path normalization code unconditionally prepends / to all path values:
if (strpos($key, '_path') !== false || strpos($key, '_url') !== false) {
$data[$key] = preg_replace('#/+#', '/', ('/' . trim($data[$key], '/') . '/'));
}On Linux this works fine:
/var/www/site/core/ → trim → var/www/site/core → prepend / → /var/www/site/core/ ✅
On Windows it breaks:
D:/laragon/www/site/core/ → trim → D:/laragon/www/site/core → prepend / → /D:/laragon/www/site/core/ ❌
The resulting config.xml contains invalid paths like:
<core_path>/D:\laragon\www\site/core/</core_path>Suggested Fix
Skip the / prepend when the path starts with a Windows drive letter:
if (strpos($key, '_path') !== false || strpos($key, '_url') !== false) {
$value = trim($data[$key], '/');
// Don't prepend / for Windows absolute paths (e.g. D:/...)
if (!preg_match('#^[A-Za-z]:#', $value)) {
$value = '/' . $value;
}
$data[$key] = preg_replace('#/+#', '/', $value . '/');
}Workaround
Generate setup/config.xml manually with correct Windows paths, then run:
php setup/index.php --installmode=new --core_path=D:/path/to/site/core/ --config=D:/path/to/site/setup/config.xmlEnvironment
- MODX 3.x (branch
3.x, commit dd8b86c) - Windows 10/11
- PHP 8.3
- Laragon local development environment
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
bugThe issue in the code or project, which should be addressed.The issue in the code or project, which should be addressed.