{"record":{"id":"7c762e0b02ae9398","repo":"hcengineering/platform","slug":"error-building-local-installation-folder-path-j","errorCode":null,"errorMessage":"Error building local installation folder (${path.join(baseFolder, ...pathSegments)}): ${e}","messagePattern":"Error building local installation folder \\((.+?)\\): (.+?)","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"foundations/net/common/scripts/install-run.js","lineNumber":425,"sourceCode":"/**\n * Create missing directories under the specified base directory, and return the resolved directory.\n *\n * Does not support \".\" or \"..\" path segments.\n * Assumes the baseFolder exists.\n */\nfunction _ensureAndJoinPath(baseFolder, ...pathSegments) {\n    let joinedPath = baseFolder;\n    try {\n        for (let pathSegment of pathSegments) {\n            pathSegment = pathSegment.replace(/[\\\\\\/]/g, '+');\n            joinedPath = path__WEBPACK_IMPORTED_MODULE_3__.join(joinedPath, pathSegment);\n            if (!fs__WEBPACK_IMPORTED_MODULE_1__.existsSync(joinedPath)) {\n                fs__WEBPACK_IMPORTED_MODULE_1__.mkdirSync(joinedPath);\n            }\n        }\n    }\n    catch (e) {\n        throw new Error(`Error building local installation folder (${path__WEBPACK_IMPORTED_MODULE_3__.join(baseFolder, ...pathSegments)}): ${e}`);\n    }\n    return joinedPath;\n}\nfunction _getRushTempFolder(rushCommonFolder) {\n    const rushTempFolder = process.env[RUSH_TEMP_FOLDER_ENV_VARIABLE_NAME];\n    if (rushTempFolder !== undefined) {\n        _ensureFolder(rushTempFolder);\n        return rushTempFolder;\n    }\n    else {\n        return _ensureAndJoinPath(rushCommonFolder, 'temp');\n    }\n}\n/**\n * Compare version strings according to semantic versioning.\n * Returns a positive integer if \"a\" is a later version than \"b\",\n * a negative integer if \"b\" is later than \"a\",\n * and 0 otherwise.","sourceCodeStart":407,"sourceCodeEnd":443,"githubUrl":"https://github.com/hcengineering/platform/blob/63e28dc96483967b2fc21c881b3f1023c1de7718/foundations/net/common/scripts/install-run.js#L407-L443","documentation":"_ensureAndJoinPath builds a directory chain under a base folder, creating each segment with mkdirSync if missing, and wraps any fs error in this Error naming the full joined path. It underpins the rush temp/recycler/package-install/common folders, so a failure here aborts the bootstrap before npm can run.","triggerScenarios":"_getRushTempFolder / rushRecyclerFolder / packageInstallFolder / rushCommonFolder call _ensureAndJoinPath and an fs operation fails: EACCES creating the folder, EPERM, path exists as a FILE (EEXIST/ENOTDIR), disk full, or read-only volume.","commonSituations":"RUSH_TEMP_FOLDER env var points somewhere unwritable; ~/rush or the repo's common/temp owned by root after a sudo run; the target path exists as a file; CI runners with read-only HOME.","solutions":["Set RUSH_TEMP_FOLDER to a writable directory to relocate the temp root.","Check ownership/permissions of ~/.rush and <repo>/common/temp; chown/chmod (fix dirs previously created with sudo: sudo chown -R $(whoami) ~/.rush).","Remove a conflicting file at the reported joined path so mkdir can create a folder there.","Free disk space or remount the volume read-write if the cause is ENOSPC/EROFS."],"exampleFix":"// before\nsudo rush install   # creates ~/.rush owned by root\nrush install        # Error building local installation folder (/home/me/.rush/...): EACCES\n// after\nsudo chown -R $(whoami) ~/.rush\nrush install","handlingStrategy":"validation","validationCode":"const base = process.env.RUSH_TEMP_FOLDER ?? path.join(os.homedir(), '.rush')\nfs.mkdirSync(base, { recursive: true })\nfs.accessSync(base, fs.constants.W_OK) // throws EACCES early with a clear path","typeGuard":null,"tryCatchPattern":"try {\n  ensureRushFolders()\n} catch (e) {\n  if (e.message.startsWith('Error building local installation folder')) {\n    const p = e.message.match(/\\(([^)]+)\\)/)?.[1]\n    console.error(`Cannot create ${p} — check ownership/permissions or set RUSH_TEMP_FOLDER`)\n  }\n  throw e\n}","preventionTips":["Never run rush installs under sudo; if you did, chown ~/.rush back to your user.","Point RUSH_TEMP_FOLDER at a known-writable dir in CI and containers.","Ensure the target path is not occupied by a regular file before bootstrap.","Monitor disk space on volumes hosting the rush temp folders."],"tags":["filesystem","permissions","rush"],"backgroundTag":"folder-creation-failed","analyzedSha":"63e28dc96483967b2fc21c881b3f1023c1de7718","analyzedAt":"2026-08-29T15:21:27.377Z","schemaVersion":2},"datasetVersion":"2026-08-29T17:17:51.833Z"}