{"record":{"id":"48773e99858df02a","repo":"hcengineering/platform","slug":"error-cleaning-the-package-install-folder-packa","errorCode":null,"errorMessage":"Error cleaning the package install folder (${packageInstallFolder}): ${e}","messagePattern":"Error cleaning the package install folder \\((.+?)\\): (.+?)","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"foundations/communication/common/scripts/install-run.js","lineNumber":607,"sourceCode":"    try {\n        const flagFile = path__WEBPACK_IMPORTED_MODULE_3__.resolve(packageInstallFolder, INSTALLED_FLAG_FILENAME);\n        _deleteFile(flagFile);\n        const packageLockFile = path__WEBPACK_IMPORTED_MODULE_3__.resolve(packageInstallFolder, 'package-lock.json');\n        if (lockFilePath) {\n            fs__WEBPACK_IMPORTED_MODULE_1__.copyFileSync(lockFilePath, packageLockFile);\n        }\n        else {\n            // Not running `npm ci`, so need to cleanup\n            _deleteFile(packageLockFile);\n            const nodeModulesFolder = path__WEBPACK_IMPORTED_MODULE_3__.resolve(packageInstallFolder, NODE_MODULES_FOLDER_NAME);\n            if (fs__WEBPACK_IMPORTED_MODULE_1__.existsSync(nodeModulesFolder)) {\n                const rushRecyclerFolder = _ensureAndJoinPath(rushTempFolder, 'rush-recycler');\n                fs__WEBPACK_IMPORTED_MODULE_1__.renameSync(nodeModulesFolder, path__WEBPACK_IMPORTED_MODULE_3__.join(rushRecyclerFolder, `install-run-${Date.now().toString()}`));\n            }\n        }\n    }\n    catch (e) {\n        throw new Error(`Error cleaning the package install folder (${packageInstallFolder}): ${e}`);\n    }\n}\nfunction _createPackageJson(packageInstallFolder, name, version) {\n    try {\n        const packageJsonContents = {\n            name: 'ci-rush',\n            version: '0.0.0',\n            dependencies: {\n                [name]: version\n            },\n            description: \"DON'T WARN\",\n            repository: \"DON'T WARN\",\n            license: 'MIT'\n        };\n        const packageJsonPath = path__WEBPACK_IMPORTED_MODULE_3__.join(packageInstallFolder, PACKAGE_JSON_FILENAME);\n        fs__WEBPACK_IMPORTED_MODULE_1__.writeFileSync(packageJsonPath, JSON.stringify(packageJsonContents, undefined, 2));\n    }\n    catch (e) {","sourceCodeStart":589,"sourceCodeEnd":625,"githubUrl":"https://github.com/hcengineering/platform/blob/63e28dc96483967b2fc21c881b3f1023c1de7718/foundations/communication/common/scripts/install-run.js#L589-L625","documentation":"_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.","triggerScenarios":"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.","commonSituations":"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.","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."],"exampleFix":"// before: shared temp between parallel jobs\n// (both jobs use ~/.rush temp)\n// after: per-job temp\nexport RUSH_TEMP_FOLDER=\"$RUNNER_TEMP/rush-$CI_JOB_ID\"","handlingStrategy":"validation","validationCode":"const folder = process.env.RUSH_TEMP_FOLDER || require('os').tmpdir();\nconst fs = require('fs');\nconst stat = fs.statSync(folder);\nfs.accessSync(folder, fs.constants.W_OK | fs.constants.X_OK);\nif (fs.existsSync(folder) && !stat.isDirectory()) throw new Error('RUSH_TEMP_FOLDER must be a writable directory');","typeGuard":null,"tryCatchPattern":"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; }","preventionTips":["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"],"tags":["filesystem","rush","concurrency"],"backgroundTag":"folder-cleanup-failed","analyzedSha":"63e28dc96483967b2fc21c881b3f1023c1de7718","analyzedAt":"2026-08-29T15:21:27.377Z","schemaVersion":2},"datasetVersion":"2026-08-29T17:17:51.833Z"}