{"record":{"id":"cf50f472cd20212e","repo":"can1357/oh-my-pi","slug":"host-file-does-not-exist-hostpath","errorCode":null,"errorMessage":"Host file does not exist: ${hostPath}","messagePattern":"Host file does not exist: (.+?)","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"packages/metaharness/src/tb/vmon.ts","lineNumber":248,"sourceCode":"\n\t/** Run a captured shell command inside the guest. */\n\tasync exec(command: string, opts: VmonExecOptions = {}): Promise<VmonCommandResult> {\n\t\tconst result = await this.#sandbox.run([\"sh\", \"-c\", command], {\n\t\t\tenv: { ...this.#env, HOME: this.home, ...opts.env },\n\t\t\tworkdir: opts.cwd === null ? null : (opts.cwd ?? this.workdir),\n\t\t\ttimeout: opts.timeoutSec,\n\t\t});\n\t\treturn {\n\t\t\texitCode: result.exit,\n\t\t\tstdout: decodeBase64(result.stdout_b64),\n\t\t\tstderr: decodeBase64(result.stderr_b64),\n\t\t};\n\t}\n\n\t/** Stream one host file into the guest without a gRPC message-size copy. */\n\tasync copyTo(hostPath: string, guestPath: string): Promise<void> {\n\t\tconst file = Bun.file(hostPath);\n\t\tif (!(await file.exists())) throw new Error(`Host file does not exist: ${hostPath}`);\n\t\tconst result = await this.#pipeInput(\n\t\t\tfile,\n\t\t\t[\n\t\t\t\t\"sh\",\n\t\t\t\t\"-c\",\n\t\t\t\t`mkdir -p ${quoteGuestShell(path.posix.dirname(guestPath))} && cat > ${quoteGuestShell(guestPath)}`,\n\t\t\t],\n\t\t\t900,\n\t\t);\n\t\tif (result.exitCode !== 0) throw commandError(`Uploading ${hostPath} to ${this.name}:${guestPath}`, result);\n\t}\n\n\t/** Stream a host directory as a gzip-compressed tar archive into the guest. */\n\tasync copyDirectory(hostDir: string, guestDir: string): Promise<void> {\n\t\tconst archive = await archiveDirectory(hostDir);\n\t\tconst result = await this.#pipeInput(\n\t\t\tarchive,\n\t\t\t[\"sh\", \"-c\", `mkdir -p ${quoteGuestShell(guestDir)} && tar xzf - -C ${quoteGuestShell(guestDir)}`],","sourceCodeStart":230,"sourceCodeEnd":266,"githubUrl":"https://github.com/can1357/oh-my-pi/blob/969062200754ea02cfac922e5ebb8c608c079e15/packages/metaharness/src/tb/vmon.ts#L230-L266","documentation":"VibemonSandbox.copyTo streams a host file into the guest. Before piping, it checks Bun.file(hostPath).exists() and throws this error if the source file is absent, so the guest never receives an empty/partial file silently.","triggerScenarios":"Calling copyTo with a hostPath that does not exist on the host — e.g. installAgent referencing an agent entrypoint binary path that was never built or is misconfigured.","commonSituations":"Forgetting to build the agent binary before installing; a wrong binaries path in opts; typos or platform-specific paths (Windows vs POSIX) pointing at a non-existent file.","solutions":["Verify the hostPath exists (ls the path) before calling copyTo","Build the agent binary/entrypoint first if installAgent depends on a build artifact","Fix the binaries/entrypoint configuration that produced the wrong path","Check for platform-specific path issues when running on a different OS"],"exampleFix":"// before\nawait vm.copyTo(path.join(binaries.agent, \"entry\"), \"/opt/agent/entry\");\n// after: fail early with a clear message\nif (!existsSync(agentEntry)) throw new Error(`Build agent first: ${agentEntry} missing`);\nawait vm.copyTo(agentEntry, \"/opt/agent/entry\");","handlingStrategy":"validation","validationCode":"const file = Bun.file(hostPath);\nif (!(await file.exists())) {\n  throw new Error(`Refusing to copyTo: missing host file ${hostPath} (build it first?)`);\n}\nawait vm.copyTo(hostPath, guestPath);","typeGuard":null,"tryCatchPattern":"try {\n  await vm.copyTo(hostPath, guestPath);\n} catch (err) {\n  if (String(err.message).startsWith(\"Host file does not exist\")) {\n    throw new Error(`${err.message} — run the agent build step before installAgent`);\n  }\n  throw err;\n}","preventionTips":["Make the agent binary build an explicit prerequisite step before installing","Assert built artifacts exist in CI before trial runs","Resolve binary paths relative to a single config source to avoid typos"],"tags":["file-transfer","vm","missing-file"],"backgroundTag":"source-file-not-found","analyzedSha":"969062200754ea02cfac922e5ebb8c608c079e15","analyzedAt":"2026-08-31T10:29:35.737Z","schemaVersion":2},"datasetVersion":"2026-08-31T14:17:45.589Z"}