{"record":{"id":"857f8d32fa7bf11c","repo":"hcengineering/platform","slug":"unable-to-create-installed-flag-file-in-packagei-857f8d","errorCode":null,"errorMessage":"Unable to create installed.flag file in ${packageInstallFolder}","messagePattern":"Unable to create installed\\.flag file in (.+?)","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"foundations/server/common/scripts/install-run.js","lineNumber":678,"sourceCode":"/**\n * Returns a cross-platform path - windows must enclose any path containing spaces within double quotes.\n */\nfunction _getPlatformPath(platformPath) {\n    return _isWindows() && platformPath.includes(' ') ? `\"${platformPath}\"` : platformPath;\n}\nfunction _isWindows() {\n    return os__WEBPACK_IMPORTED_MODULE_2__.platform() === 'win32';\n}\n/**\n * Write a flag file to the package's install directory, signifying that the install was successful.\n */\nfunction _writeFlagFile(packageInstallFolder) {\n    try {\n        const flagFilePath = path__WEBPACK_IMPORTED_MODULE_3__.join(packageInstallFolder, INSTALLED_FLAG_FILENAME);\n        fs__WEBPACK_IMPORTED_MODULE_1__.writeFileSync(flagFilePath, process.version);\n    }\n    catch (e) {\n        throw new Error(`Unable to create installed.flag file in ${packageInstallFolder}`);\n    }\n}\nfunction installAndRun(logger, packageName, packageVersion, packageBinName, packageBinArgs, lockFilePath = process.env[INSTALL_RUN_LOCKFILE_PATH_VARIABLE]) {\n    const rushJsonFolder = findRushJsonFolder();\n    const rushCommonFolder = path__WEBPACK_IMPORTED_MODULE_3__.join(rushJsonFolder, 'common');\n    const rushTempFolder = _getRushTempFolder(rushCommonFolder);\n    const packageInstallFolder = _ensureAndJoinPath(rushTempFolder, 'install-run', `${packageName}@${packageVersion}`);\n    if (!_isPackageAlreadyInstalled(packageInstallFolder)) {\n        // The package isn't already installed\n        _cleanInstallFolder(rushTempFolder, packageInstallFolder, lockFilePath);\n        const sourceNpmrcFolder = path__WEBPACK_IMPORTED_MODULE_3__.join(rushCommonFolder, 'config', 'rush');\n        (0,_utilities_npmrcUtilities__WEBPACK_IMPORTED_MODULE_4__.syncNpmrc)({\n            sourceNpmrcFolder,\n            targetNpmrcFolder: packageInstallFolder,\n            logger,\n            supportEnvVarFallbackSyntax: false\n        });\n        _createPackageJson(packageInstallFolder, packageName, packageVersion);","sourceCodeStart":660,"sourceCodeEnd":696,"githubUrl":"https://github.com/hcengineering/platform/blob/63e28dc96483967b2fc21c881b3f1023c1de7718/foundations/server/common/scripts/install-run.js#L660-L696","documentation":"After a successful install, _writeFlagFile writes installed.flag containing the current Node version so later runs can skip re-installation when the Node version is unchanged. If writing the flag file fails, this error is thrown, meaning the install succeeded but the caching marker could not be persisted.","triggerScenarios":"fs.writeFileSync on common/temp/install-run/<pkg>/installed.flag fails due to missing folder, read-only filesystem, disk full, or AV/permission interference on Windows.","commonSituations":"Read-only CI workspace mounts; disk quota reached right after npm install filled the disk; two concurrent install-run runs racing to write the same flag file.","solutions":["Ensure common/temp/install-run and the package folder are writable; check disk space and quota","Remove common/temp/install-run and re-run the script to rebuild the folder cleanly","Avoid concurrent install-run executions for the same repo/lock combination","On Windows, check antivirus/file-lock interference with the temp folder"],"exampleFix":null,"handlingStrategy":"try-catch","validationCode":"const fs = require('fs')\nconst dir = 'common/temp/install-run'\nfs.mkdirSync(dir, { recursive: true })\nfs.accessSync(dir, fs.constants.W_OK)","typeGuard":null,"tryCatchPattern":"try {\n  installAndRun(logger, pkg, version, bin, args)\n} catch (e) {\n  if (e.message.startsWith('Unable to create installed.flag')) {\n    // install likely succeeded; check node_modules and clear flag state to retry cleanly\n    fs.rmSync('common/temp/install-run', { recursive: true, force: true })\n    installAndRun(logger, pkg, version, bin, args)\n  } else throw e\n}","preventionTips":["Monitor disk space/quota on CI machines","Avoid read-only mounts over common/temp","Prevent concurrent install-run executions"],"tags":["rush","filesystem","cache-flag"],"backgroundTag":"filesystem-write-failed","analyzedSha":"63e28dc96483967b2fc21c881b3f1023c1de7718","analyzedAt":"2026-08-29T15:21:27.377Z","schemaVersion":2},"datasetVersion":"2026-08-29T17:17:51.833Z"}