hcengineering/platform · error · Error
Error cleaning the package install folder (${packageInstallF
Error message
Error cleaning the package install folder (${packageInstallFolder}): ${e} What it means
_cleanInstallFolder prepares the package install folder: if the folder already exists and is not a valid prior install, it renames node_modules into the rush-recycler folder (or otherwise removes leftovers). Any filesystem failure during this cleanup — permission denied, cross-device rename, locked files — is wrapped as this error.
Source
Thrown at foundations/communication/common/scripts/install-run.js:607
try {
const flagFile = path__WEBPACK_IMPORTED_MODULE_3__.resolve(packageInstallFolder, INSTALLED_FLAG_FILENAME);
_deleteFile(flagFile);
const packageLockFile = path__WEBPACK_IMPORTED_MODULE_3__.resolve(packageInstallFolder, 'package-lock.json');
if (lockFilePath) {
fs__WEBPACK_IMPORTED_MODULE_1__.copyFileSync(lockFilePath, packageLockFile);
}
else {
// Not running `npm ci`, so need to cleanup
_deleteFile(packageLockFile);
const nodeModulesFolder = path__WEBPACK_IMPORTED_MODULE_3__.resolve(packageInstallFolder, NODE_MODULES_FOLDER_NAME);
if (fs__WEBPACK_IMPORTED_MODULE_1__.existsSync(nodeModulesFolder)) {
const rushRecyclerFolder = _ensureAndJoinPath(rushTempFolder, 'rush-recycler');
fs__WEBPACK_IMPORTED_MODULE_1__.renameSync(nodeModulesFolder, path__WEBPACK_IMPORTED_MODULE_3__.join(rushRecyclerFolder, `install-run-${Date.now().toString()}`));
}
}
}
catch (e) {
throw new Error(`Error cleaning the package install folder (${packageInstallFolder}): ${e}`);
}
}
function _createPackageJson(packageInstallFolder, name, version) {
try {
const packageJsonContents = {
name: 'ci-rush',
version: '0.0.0',
dependencies: {
[name]: version
},
description: "DON'T WARN",
repository: "DON'T WARN",
license: 'MIT'
};
const packageJsonPath = path__WEBPACK_IMPORTED_MODULE_3__.join(packageInstallFolder, PACKAGE_JSON_FILENAME);
fs__WEBPACK_IMPORTED_MODULE_1__.writeFileSync(packageJsonPath, JSON.stringify(packageJsonContents, undefined, 2));
}
catch (e) {View on GitHub (pinned to 63e28dc964)
Solutions
- Manually delete the stale install folder (and node_modules) and rerun.
- Ensure RUSH_TEMP_FOLDER is on the same volume and writable by the script user.
- Stop concurrent jobs/agents that use the same temp folder, or give each job a unique RUSH_TEMP_FOLDER.
- On Windows, close editors/AV scanners that lock files, or reboot the runner to release locks.
Example fix
// before: shared temp between parallel jobs // (both jobs use ~/.rush temp) // after: per-job temp export RUSH_TEMP_FOLDER="$RUNNER_TEMP/rush-$CI_JOB_ID"
Defensive patterns
Strategy: validation
Validate before calling
const folder = process.env.RUSH_TEMP_FOLDER || require('os').tmpdir();
const fs = require('fs');
const stat = fs.statSync(folder);
fs.accessSync(folder, fs.constants.W_OK | fs.constants.X_OK);
if (fs.existsSync(folder) && !stat.isDirectory()) throw new Error('RUSH_TEMP_FOLDER must be a writable directory'); Try / catch
try { runInstall(); } catch (e) { if (/Error cleaning the package install folder/.test(e.message)) { console.error('Delete the stale install folder or set a unique RUSH_TEMP_FOLDER per job'); process.exit(1); } throw e; } Prevention
- Give each CI job its own RUSH_TEMP_FOLDER to avoid concurrency conflicts
- Keep temp and recycler folders on the same volume (avoid EXDEV)
- Disable AV/backup locking on the temp folder in Windows runners
When it happens
Trigger: installAndRun calls _cleanInstallFolder and the renameSync/unlink of the existing node_modules or install folder fails: read-only volume, target drive differs (EXDEV on rename across devices), files locked by another process, or the rush-recycler folder couldn't be created.
Common situations: Concurrent CI jobs sharing the same temp install folder; antivirus/backup holding files on Windows; temp folder and recycler folder on different mounts; leftover locked .bin shims from a killed run.
Related errors
- Error building local installation folder (${path__WEBPACK_IM
- Unable to create installed.flag file in ${packageInstallFold
- Error building local installation folder (${path.join(baseFo
- Error cleaning the package install folder (${packageInstallF
- Unable to create installed.flag file in ${packageInstallFold
AI-assisted analysis of hcengineering/platform@63e28dc964 (2026-08-29).
Data as JSON: /api/errors/48773e99858df02a.
Report an issue: GitHub.