{"record":{"id":"ccc08c883491f80c","repo":"bmad-code-org/BMAD-METHOD","slug":"path-expansion-for-username-is-not-supported","errorCode":null,"errorMessage":"Path expansion for ~${username} is not supported. Please use an absolute path or ~${path.sep}","messagePattern":"Path expansion for ~(.+?) is not supported\\. Please use an absolute path or ~(.+?)","errorType":"validation","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"tools/installer/ui.js","lineNumber":1676,"sourceCode":"    if (typeof inputPath !== 'string') {\n      throw new TypeError('Path must be a string.');\n    }\n\n    let expanded = inputPath.trim();\n\n    // Handle tilde expansion\n    if (expanded.startsWith('~')) {\n      if (expanded === '~') {\n        expanded = os.homedir();\n      } else if (expanded.startsWith('~' + path.sep)) {\n        const pathAfterHome = expanded.slice(2); // Remove ~/ or ~\\\n        expanded = path.join(os.homedir(), pathAfterHome);\n      } else {\n        const restOfPath = expanded.slice(1);\n        const separatorIndex = restOfPath.indexOf(path.sep);\n        const username = separatorIndex === -1 ? restOfPath : restOfPath.slice(0, separatorIndex);\n        if (username) {\n          throw new Error(`Path expansion for ~${username} is not supported. Please use an absolute path or ~${path.sep}`);\n        }\n      }\n    }\n\n    // Resolve to the absolute path relative to the current working directory\n    return path.resolve(expanded);\n  }\n\n  /**\n   * Get configured IDEs from existing installation\n   * @param {string} directory - Installation directory\n   * @returns {Array} List of configured IDEs\n   */\n  async getConfiguredIdes(directory) {\n    const { ExistingInstall } = require('./core/existing-install');\n    const { Installer } = require('./core/installer');\n    const installer = new Installer();\n    const { bmadDir } = await installer.findBmadDir(directory);","sourceCodeStart":1658,"sourceCodeEnd":1694,"githubUrl":"https://github.com/bmad-code-org/BMAD-METHOD/blob/b70486b9bdcb0a404d329e2a763b57964e7f1360/tools/installer/ui.js#L1658-L1694","documentation":"Thrown by expandUserPath when the path starts with '~' but is neither '~' alone nor '~' + path.sep + rest — i.e. POSIX '~user' (home-for-another-user) syntax. The installer only resolves the current user's home via os.homedir(); other users' homes are not expanded.","triggerScenarios":"Passing --directory ~otheruser/path or --directory ~root (anything matching ~<name>... that isn't ~/).","commonSituations":"Copying a path from a root-user or another user's context; a cross-user deployment script using ~ for a different user; assuming full POSIX tilde expansion.","solutions":["Use an absolute path: /home/otheruser/path or the actual home directory.","Use '~' (current user) or '~/subdir' only — these are the supported tilde forms.","Resolve the other user's home upstream (e.g. via getent passwd) and pass the absolute path."],"exampleFix":"# before\n#   --directory ~root/bmad\n#\n# after\n#   --directory /root/bmad\n#   --directory ~/bmad        # if running as the intended user","handlingStrategy":"validation","validationCode":"function isSupportedTildeForm(p) {\n  if (typeof p !== 'string') return false;\n  if (!p.startsWith('~')) return true;\n  return p === '~' || p.startsWith('~' + path.sep);\n}\nif (!isSupportedTildeForm(options.directory)) {\n  throw new Error('Use an absolute path; ~user syntax is not supported.');\n}","typeGuard":"function isSupportedTildeForm(p) {\n  if (typeof p !== 'string' || !p.startsWith('~')) return true;\n  return p === '~' || p.startsWith('~' + path.sep);\n}","tryCatchPattern":"try {\n  dir = ui.expandUserPath(options.directory);\n} catch (e) {\n  if (/Path expansion for ~.* is not supported/.test(e.message)) {\n    // resolve the absolute home dir upstream and pass that instead\n  } else { throw e; }\n}","preventionTips":["Resolve other-user home directories to absolute paths before passing to the installer.","Restrict tilde inputs to '~' and '~/...' forms in your wrapper."],"tags":["installer","path-expansion","tilde"],"backgroundTag":null,"analyzedSha":"b70486b9bdcb0a404d329e2a763b57964e7f1360","analyzedAt":"2026-08-13T01:21:12.247Z","schemaVersion":2},"datasetVersion":"2026-08-13T04:17:16.726Z"}