hcengineering/platform · error
Unable to create installed.flag file in ${packageInstallFold
Error message
Unable to create installed.flag file in ${packageInstallFolder} What it means
After npm install completes, _writeFlagFile writes an installed.flag file into the package install folder to mark it cached. If writeFileSync fails (permissions, full disk, read-only filesystem, missing directory), this error is thrown. It means the install succeeded or ran, but the cache marker could not be persisted.
Source
Thrown at foundations/net/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
- Check write permissions on the rush temp/common install folder and fix ownership (chown/chmod) or run as a user who can write there.
- Delete the stale package install folder and re-run so it is recreated with correct permissions.
- Free disk space if the volume is full.
- Avoid running concurrent builds that share the same rush cache folder, or point INSTALL_RUN_LOCKFILE_PATH / cache to a writable location.
Example fix
// before: ~/.rush owned by root, build runs as ci user sudo chown -R $(whoami) ~/.rush node common/scripts/install-run-rush.js build // after: cache writable by the build user, script succeeds
Defensive patterns
Strategy: validation
Validate before calling
const fs = require('fs');
function cacheFolderWritable(folder) {
try { fs.mkdirSync(folder, { recursive: true }); fs.accessSync(folder, fs.constants.W_OK); return true; }
catch { return false; }
} Try / catch
try {
await runInstallRunScript(args);
} catch (e) {
if (String(e.message).startsWith('Unable to create installed.flag')) {
const folder = e.message.match(/in (.+)$/)?.[1];
console.error(`Cannot write to ${folder}: check permissions/disk space`);
process.exit(1);
}
throw e;
} Prevention
- Run builds as a user that owns the rush cache folder (~/.rush).
- Never mount the cache directory read-only.
- Monitor disk space on CI runners.
- Avoid concurrent builds sharing one rush temp folder.
When it happens
Trigger: Running an install-run shim script when fs.writeFileSync cannot create installed.flag inside the rush temp package folder — e.g. directory owned by root/another user, read-only mount, or the folder was deleted mid-run.
Common situations: CI containers running as non-root but reusing a root-owned ~/.rush cache; Docker volumes mounted read-only; disk-quota exhaustion; multiple concurrent builds racing on the same temp folder.
Understand the failure class
Background: Permission denied / not authorized / 403 Forbidden: access-control rejections when the caller lacks the required role, grant, or ownership — this error's family across 18 libraries.
Related errors
- Unable to create installed.flag file in ${packageInstallFold
- Error building local installation folder (${path__WEBPACK_IM
- Error building local installation folder (${path.join(baseFo
- Error building local installation folder (${path__WEBPACK_IM
- Error cleaning the package install folder (${packageInstallF
AI-assisted analysis of hcengineering/platform@63e28dc964 (2026-08-29).
Data as JSON: /api/errors/98d7e0a5d258faf4.
Report an issue: GitHub.