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 common/temp/install-run-<id> for a fresh install; if a stale install folder exists it moves node_modules into the rush-recycler folder via renameSync. Any filesystem failure during this cleanup (delete/rename of the package install folder) is rethrown wrapped as 'Error cleaning the package install folder (...)'.
Source
Thrown at foundations/core/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
- Ensure no other process/CI job is using the same checkout; run installs serially or with separate workspaces.
- Stop processes holding files open (dev servers, editors, antivirus scans) then delete common/temp manually.
- Manually remove common/temp/install-run-* and rush-recycler contents with elevated permissions if needed.
- Check filesystem permissions/free space on the volume hosting common/temp.
Example fix
// before (retry on locked folder) npx install-run-rush.js // after rm -rf common/temp/install-run-* common/temp/rush-recycler && npx install-run-rush.js
Defensive patterns
Strategy: try-catch
Validate before calling
const fs = require('fs');
function assertTempWritable(repoRoot) {
const temp = require('path').join(repoRoot, 'common', 'temp');
fs.mkdirSync(temp, { recursive: true });
fs.accessSync(temp, fs.constants.W_OK);
}
assertTempWritable(process.cwd()); Type guard
function isInstallFolderClean(folder) {
const fs = require('fs');
return !fs.existsSync(folder); // no stale folder to clean
} Try / catch
try {
installAndRun(logger, name, version, bin, args);
} catch (e) {
if (/Error cleaning the package install folder/.test(e.message)) {
const fs = require('fs');
fs.rmSync('common/temp/install-run-*', { recursive: true, force: true });
return installAndRun(logger, name, version, bin, args); // one clean retry
}
throw e;
} Prevention
- Run only one install/bootstrap per checkout at a time
- Exclude common/temp from antivirus real-time scanning on CI agents
- Verify disk space and write permissions before CI runs
- Clean common/temp between pipeline stages
When it happens
Trigger: installAndRun detects an existing/incomplete install folder and tries to remove or rename it, but the OS call fails — e.g. EBUSY/EPERM because files are locked, EACCES from permissions, or ENOTEMPTY on the rename into rush-recycler.
Common situations: Parallel CI jobs sharing the same repo checkout (concurrent installs racing on common/temp); antivirus or a running dev server holding files in node_modules on Windows; read-only or quota-exceeded volumes; leftover root-owned files from a container run.
Related errors
- Unable to create package.json: ${e}
- "npm ${command}" encountered an error
- Unable to create installed.flag file in ${packageInstallFold
- Error cleaning the package install folder (${packageInstallF
- The NPM executable does not exist
AI-assisted analysis of hcengineering/platform@63e28dc964 (2026-08-29).
Data as JSON: /api/errors/386dd8c11dd135fe.
Report an issue: GitHub.