hcengineering/platform · error · Error

Unable to create installed.flag file in ${packageInstallFold

Error message

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

What it means

After installing a package, install-run.js writes an installed.flag file (containing the Node version) into the package install folder so subsequent runs can skip reinstalling. If writeFileSync fails, this Error is thrown. The package may actually be installed, but the shim cannot mark it as done.

Source

Thrown at foundations/communication/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. Ensure the rush common/temp directory (and package install folder) is writable by the current user.
  2. Remove stale/partial temp install folders and re-run the bootstrap.
  3. Check disk space (ENOSPC) and antivirus/file-lock interference if on Windows.
  4. Run the script with elevated permissions only if the mount is intentionally restricted — otherwise fix mount options (e.g. don't mount repo read-only during bootstrap).

Example fix

// before
docker run -v $PWD:/repo:ro node:18 /repo/common/scripts/install-run-rush.js install
// Error: Unable to create installed.flag file in ...
// after
// mount writable
docker run -v $PWD:/repo node:18 /repo/common/scripts/install-run-rush.js install
Defensive patterns

Strategy: validation

Validate before calling

const fs = require('fs')
const tempDir = 'common/temp'
fs.accessSync(tempDir, fs.constants.W_OK) // throws early if not writable

Try / catch

try {
  runInstallRun()
} catch (e) {
  if (String(e).includes('installed.flag')) {
    console.error('Temp dir not writable or disk full; fix permissions and retry')
  }
  throw e
}

Prevention

When it happens

Trigger: Running any install-run bootstrap where fs.writeFileSync cannot create installed.flag in the rush temp package folder — read-only directory, permission denied, path missing, or antivirus/file locking on Windows.

Common situations: CI containers running as non-root with a read-only repo mount; Docker images with restricted write access to common/temp; concurrent builds racing over the same temp folder; full disk.

Related errors


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