hcengineering/platform · error

Unable to create installed.flag file in ${packageInstallFold

Error message

Unable to create installed.flag file in ${packageInstallFolder}

What it means

install-run.js bootstraps a Rush repo by installing a tool package into a temp folder and writes an installed.flag file (containing the node version) to mark the package as installed. The flag write uses fs.writeFileSync inside a try/catch; any failure (permissions, missing folder, read-only disk) is converted into this opaque error. It guards against repeatedly attempting installs when the environment cannot support them.

Source

Thrown at foundations/utils/common/scripts/install-run.js:678

/**
 * Returns a cross-platform path - windows must enclose any path containing spaces within double quotes.
 */
function _getPlatformPath(platformPath) {
    return _isWindows() && platformPath.includes(' ') ? `"${platformPath}"` : platformPath;
}
function _isWindows() {
    return os__WEBPACK_IMPORTED_MODULE_2__.platform() === 'win32';
}
/**
 * Write a flag file to the package's install directory, signifying that the install was successful.
 */
function _writeFlagFile(packageInstallFolder) {
    try {
        const flagFilePath = path__WEBPACK_IMPORTED_MODULE_3__.join(packageInstallFolder, INSTALLED_FLAG_FILENAME);
        fs__WEBPACK_IMPORTED_MODULE_1__.writeFileSync(flagFilePath, process.version);
    }
    catch (e) {
        throw new Error(`Unable to create installed.flag file in ${packageInstallFolder}`);
    }
}
function installAndRun(logger, packageName, packageVersion, packageBinName, packageBinArgs, lockFilePath = process.env[INSTALL_RUN_LOCKFILE_PATH_VARIABLE]) {
    const rushJsonFolder = findRushJsonFolder();
    const rushCommonFolder = path__WEBPACK_IMPORTED_MODULE_3__.join(rushJsonFolder, 'common');
    const rushTempFolder = _getRushTempFolder(rushCommonFolder);
    const packageInstallFolder = _ensureAndJoinPath(rushTempFolder, 'install-run', `${packageName}@${packageVersion}`);
    if (!_isPackageAlreadyInstalled(packageInstallFolder)) {
        // The package isn't already installed
        _cleanInstallFolder(rushTempFolder, packageInstallFolder, lockFilePath);
        const sourceNpmrcFolder = path__WEBPACK_IMPORTED_MODULE_3__.join(rushCommonFolder, 'config', 'rush');
        (0,_utilities_npmrcUtilities__WEBPACK_IMPORTED_MODULE_4__.syncNpmrc)({
            sourceNpmrcFolder,
            targetNpmrcFolder: packageInstallFolder,
            logger,
            supportEnvVarFallbackSyntax: false
        });
        _createPackageJson(packageInstallFolder, packageName, packageVersion);

View on GitHub (pinned to 63e28dc964)

Solutions

  1. Check write permissions on the <repo>/common/temp (or _getRushTempFolder) directory and fix ownership (chown/chmod).
  2. Delete the rush temp folder (common/temp/install-run-* or similar) to clear stale state and retry.
  3. Free disk space / close programs locking the folder (antivirus, editors).
  4. Run the script with the same user/privileges that owns the repo checkout.

Example fix

// before
npx install-run-rush install  // fails: Unable to create installed.flag file in ...
// after
rm -rf common/temp/install-run-*
chmod u+w common/temp
npx install-run-rush install
Defensive patterns

Strategy: try-catch

Validate before calling

const fs = require('fs')
if (!fs.accessSync(tempFolder, fs.constants.W_OK)) throw new Error(`no write access to ${tempFolder}`)

Try / catch

try {
  await runInstallRunner()
} catch (e) {
  if (/Unable to create installed.flag/.test(e.message)) {
    fs.rmSync(tempFolder, { recursive: true, force: true })
    await runInstallRunner() // retry after clearing stale temp
  } else throw e
}

Prevention

When it happens

Trigger: installAndRun resolves a package into packageInstallFolder and then calls _writeFlagFile; writeFileSync throws (e.g. common/temp exists but is not writable, disk full, antivirus lock, or the install folder was deleted between install and flag write).

Common situations: Running Rush-related scripts as a different user than the one who created common/temp; CI containers with read-only or restricted common/ directories; Node version changes conflicting with a stale or locked temp folder.

Related errors


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