{"record":{"id":"d4b233bdbabbc935","repo":"ComposioHQ/composio","slug":"cannot-determine-save-location-home-directory-is","errorCode":null,"errorMessage":"Cannot determine save location: home directory is not available","messagePattern":"Cannot determine save location: home directory is not available","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"ts/packages/core/src/models/RemoteFile.ts","lineNumber":160,"sourceCode":"   * Downloads and saves the file to the local filesystem.\n   * Requires a Node.js runtime with file system support (not available in Cloudflare Workers/Edge).\n   *\n   * @param path - Local path to save the file. If omitted, saves to the Composio temp directory using the filename from the mount path.\n   * @returns The absolute path where the file was saved\n   * @throws Error if file system is not supported or the save fails\n   */\n  async save(path?: string): Promise<string> {\n    if (!platform.supportsFileSystem) {\n      throw new Error(\n        'File system operations are not supported in this runtime (e.g. Cloudflare Workers). ' +\n          'Use buffer(), text(), or blob() to work with the file content in memory, or run in Node.js.'\n      );\n    }\n\n    const content = await this.buffer();\n    const homeDir = platform.homedir();\n    if (!homeDir) {\n      throw new Error('Cannot determine save location: home directory is not available');\n    }\n\n    const savePath =\n      path ?? platform.joinPath(homeDir, COMPOSIO_DIR, TEMP_FILES_DIRECTORY_NAME, this.filename);\n\n    const dir =\n      path != null\n        ? getParentDir(savePath)\n        : platform.joinPath(homeDir, COMPOSIO_DIR, TEMP_FILES_DIRECTORY_NAME);\n    if (dir && !platform.existsSync(dir)) {\n      platform.mkdirSync(dir);\n    }\n\n    platform.writeFileSync(savePath, content);\n    return savePath;\n  }\n}\n","sourceCodeStart":142,"sourceCodeEnd":178,"githubUrl":"https://github.com/ComposioHQ/composio/blob/64b1b85502b1beeb2379e6c9e8bf1104504fa637/ts/packages/core/src/models/RemoteFile.ts#L142-L178","documentation":"RemoteFile.save() needs a home directory to compute the default destination (~/.composio/temp-files/<filename>) when no explicit path is given, and platform.homedir() returned a falsy value in this runtime.","triggerScenarios":"Calling await file.save() with no path in an environment where HOME/UserProfile is unset — containers with a bare env, certain serverless/edge sandboxes, or service accounts without a home dir.","commonSituations":"Docker images running with empty env; CI jobs scrubbing HOME; running under a daemon user with no home directory.","solutions":["Pass an explicit absolute path: await file.save('/var/tmp/file.pdf')","Set HOME (or the platform's home env var) in the container/service environment","Pre-create the target directory if your runtime also restricts writes"],"exampleFix":"// before\nawait file.save();\n// after\nawait file.save(path.join(os.tmpdir(), file.filename));","handlingStrategy":"validation","validationCode":"const target = path ?? '/tmp/' + file.filename; // explicit path avoids homedir lookup\nawait file.save(target);","typeGuard":"const hasHomeDir = (): boolean => Boolean(platform.homedir());","tryCatchPattern":"try { await file.save(); } catch (e) { if (/home directory is not available/.test(String(e?.message))) { return file.save('/tmp/' + file.filename); } throw e; }","preventionTips":["Always pass an explicit absolute path to save() in containers","Set HOME in minimal Docker images","Verify the process user has a writable home or tmp dir"],"tags":["files","save","environment","home-directory"],"backgroundTag":"missing-home-directory","analyzedSha":"64b1b85502b1beeb2379e6c9e8bf1104504fa637","analyzedAt":"2026-08-28T15:39:33.623Z","schemaVersion":2},"datasetVersion":"2026-08-28T16:17:29.566Z"}