hcengineering/platform · error

Error cleaning the package install folder (${packageInstallF

Error message

Error cleaning the package install folder (${packageInstallFolder}): ${e}

What it means

During installAndRun, _cleanInstallFolder prepares the temporary package install folder by deleting installed.flag, copying/removing the lockfile, and moving any existing node_modules into a rush-recycler folder. If any of these filesystem operations fail (rename, copy, unlink), the underlying exception is wrapped and rethrown with the install folder path in the message.

Source

Thrown at foundations/server/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

  1. Check that the lockfile path (env INSTALL_RUN_LOCKFILE_PATH_VARIABLE or lockFilePath arg) exists and is readable
  2. Fix permissions on the rush temp folder (common/temp) and ensure the disk is not full
  3. Delete common/temp/install-run and common/temp/rush-recycler leftovers, then retry the script
  4. Re-run as a user with write access to the repo's common/temp directory

Example fix

// before
INSTALL_RUN_LOCKFILE_PATH_VARIABLE=./missing/pnpm-lock.yaml node install-run.js ...
// after
ls ./common/config/rush/pnpm-lock.yaml && INSTALL_RUN_LOCKFILE_PATH_VARIABLE=./common/config/rush/pnpm-lock.yaml node install-run.js ...
Defensive patterns

Strategy: try-catch

Validate before calling

const fs = require('fs')
if (process.env.INSTALL_RUN_LOCKFILE_PATH_VARIABLE && !fs.existsSync(process.env.INSTALL_RUN_LOCKFILE_PATH_VARIABLE)) {
  throw new Error(`Lockfile not found: ${process.env.INSTALL_RUN_LOCKFILE_PATH_VARIABLE}`)
}
fs.accessSync('common/temp', fs.constants.W_OK)

Try / catch

try {
  installAndRun(logger, pkg, version, bin, args, lockFilePath)
} catch (e) {
  if (/^Error cleaning the package install folder/.test(e.message)) {
    fs.rmSync('common/temp/install-run', { recursive: true, force: true })
    installAndRun(logger, pkg, version, bin, args, lockFilePath)
  } else throw e
}

Prevention

When it happens

Trigger: fs.copyFileSync fails because the lockFilePath (INSTALL_RUN_LOCKFILE_PATH_VARIABLE or argument) does not exist or is unreadable; fs.renameSync of node_modules fails because the rush-recycler folder cannot be created or the target path already exists; permission errors deleting installed.flag/package-lock.json.

Common situations: INSTALL_RUN_LOCKFILE_PATH_VARIABLE pointing to a wrong or missing path; read-only or disk-full rush temp folder (common/temp); leftover rush-recycler entries causing rename conflicts; permission issues on shared CI caches.

Related errors


AI-assisted analysis of hcengineering/platform@63e28dc964 (2026-08-29). Data as JSON: /api/errors/7b03998b3b4d902f. Report an issue: GitHub.