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
_writeFlagFile records installed.flag (containing the Node version) in the package install folder so subsequent runs can skip reinstalling when the Node version is unchanged. If writeFileSync of that flag file fails, the error 'Unable to create installed.flag file in <folder>' is thrown. The install itself may have succeeded, but without the flag the fast-path can never trigger.
Source
Thrown at foundations/core/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
- Fix write permissions on the package install folder (chmod/chown) for the invoking user.
- Ensure no parallel process deletes or locks common/temp while the script runs.
- Free disk space if ENOSPC.
- Remove common/temp/install-run-* and rerun the bootstrap to regenerate the folder and flag.
Example fix
// before (root-owned temp from a prior sudo run) node common/scripts/install-run-rush.js // after sudo rm -rf common/temp/install-run-* && node common/scripts/install-run-rush.js
Defensive patterns
Strategy: validation
Validate before calling
const fs = require('fs');
function assertFlagWritable(folder) {
const probe = require('path').join(folder, '.write-probe');
fs.mkdirSync(folder, { recursive: true });
fs.writeFileSync(probe, 'ok');
fs.unlinkSync(probe);
}
assertFlagWritable('common/temp/install-run-probe'); Type guard
function canWriteTo(dir) {
const fs = require('fs');
try { fs.accessSync(dir, fs.constants.W_OK); return true; } catch { return false; }
} Try / catch
try {
installAndRun(logger, name, version, bin, args);
} catch (e) {
if (/Unable to create installed\.flag/.test(e.message)) {
const fs = require('fs');
fs.rmSync('common/temp/install-run-*', { recursive: true, force: true });
console.error('Install folder unwritable or raced; cleaned and aborting — rerun the bootstrap.');
}
throw e;
} Prevention
- Ensure the CI user owns common/temp (avoid root-owned dirs from prior sudo runs)
- Serialize bootstrap steps so no parallel job deletes the install folder mid-run
- Monitor free disk space on build agents
- Treat installed.flag as an optimization only — verify the install on failure
When it happens
Trigger: writeFileSync of common/temp/install-run-*/installed.flag fails due to permissions (EACCES), read-only filesystem, disk full (ENOSPC), or the install folder being deleted/raced by another process between install and flag write.
Common situations: CI runners lacking write access to repo temp dirs; concurrent pipeline stages sharing a checkout; quota-limited or read-only volumes; Windows file locking after npm install finished but files still held.
Related errors
- Unable to create installed.flag file in ${packageInstallFold
- Error cleaning the package install folder (${packageInstallF
- Unable to create package.json: ${e}
- The NPM executable does not exist
- Error building local installation folder (${path__WEBPACK_IM
AI-assisted analysis of hcengineering/platform@63e28dc964 (2026-08-29).
Data as JSON: /api/errors/4c60534e303fb224.
Report an issue: GitHub.