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.php with 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.xml
Environment
- MODX 3.x (branch
3.x, commit dd8b86c)
- Windows 10/11
- PHP 8.3
- Laragon local development environment
Description
setup/cli-install.phpcorrupts Windows file paths during the path normalization step, making CLI installation impossible on Windows.Steps to Reproduce
php setup/cli-install.phpwith all required parametersRoot Cause
The path normalization code unconditionally prepends
/to all path values: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.xmlcontains invalid paths like:Suggested Fix
Skip the
/prepend when the path starts with a Windows drive letter:Workaround
Generate
setup/config.xmlmanually with correct Windows paths, then run:Environment
3.x, commit dd8b86c)