{"record":{"id":"917153c7012daf28","repo":"aaif-goose/goose","slug":"invalid-goose-binary-path-pathfromenv-pwd-is","errorCode":null,"errorMessage":"Invalid GOOSE_BINARY path: ${pathFromEnv} (pwd is ${process.cwd()})","messagePattern":"Invalid GOOSE_BINARY path: (.+?) \\(pwd is (.+?)\\)","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"ui/desktop/src/gooseServe.ts","lineNumber":77,"sourceCode":"    return fs.existsSync(candidate) && fs.statSync(candidate).isFile();\n  } catch {\n    return false;\n  }\n};\n\nexport const findGooseBinaryPath = (options: FindGooseBinaryOptions = {}): string => {\n  const { isPackaged = false, resourcesPath } = options;\n  const pathFromEnv = process.env.GOOSE_BINARY;\n  if (pathFromEnv) {\n    if (isPackaged) {\n      throw new Error('GOOSE_BINARY is only supported in development builds');\n    }\n\n    const resolvedPath = path.resolve(pathFromEnv);\n    if (existingFile(resolvedPath)) {\n      return resolvedPath;\n    }\n    throw new Error(`Invalid GOOSE_BINARY path: ${pathFromEnv} (pwd is ${process.cwd()})`);\n  }\n\n  const binaryName = process.platform === 'win32' ? 'goose.exe' : 'goose';\n  const possiblePaths: string[] = [];\n\n  if (isPackaged && resourcesPath) {\n    possiblePaths.push(path.join(resourcesPath, 'bin', binaryName));\n    possiblePaths.push(path.join(resourcesPath, binaryName));\n  } else {\n    possiblePaths.push(\n      path.join(process.cwd(), 'src', 'bin', binaryName),\n      path.join(process.cwd(), '..', '..', 'target', 'release', binaryName),\n      path.join(process.cwd(), '..', '..', 'target', 'debug', binaryName)\n    );\n  }\n\n  for (const candidate of possiblePaths) {\n    if (existingFile(candidate)) {","sourceCodeStart":59,"sourceCodeEnd":95,"githubUrl":"https://github.com/aaif-goose/goose/blob/3810898a7447ec3299be72e223d3570a7aabf0ab/ui/desktop/src/gooseServe.ts#L59-L95","documentation":"Thrown by findGooseBinaryPath in a development build when GOOSE_BINARY is set, resolves via path.resolve to an absolute path, but existingFile() finds no regular file there. The message deliberately echoes the original env value and process.cwd() because path.resolve interprets relative GOOSE_BINARY values against the working directory — the most common cause is a relative path resolved from the wrong cwd.","triggerScenarios":"GOOSE_BINARY=goose (bare name) or ../target/release/goose while Electron starts with a cwd other than the repo root; pointing at a directory instead of the executable; the binary not built yet so the path is simply absent; Windows paths without .exe.","commonSituations":"pnpm/electron launching from ui/desktop while the var was written assuming the repo root; 'cargo build' never run; path with a typo or wrong target dir (debug vs release); scripts moving/renaming the binary.","solutions":["Use an absolute path: export GOOSE_BINARY=\"$PWD/target/release/goose\" from the repo root after building.","Confirm the file exists at the resolved location: ls the path shown after '(pwd is ...)'.","Build first: cargo build --release (or just release-binary) so target/release/goose exists.","On Windows include the .exe extension."],"exampleFix":"# before\nGOOSE_BINARY=\"../target/release/goose\" pnpm dev   # fails when cwd differs\n\n# after\nGOOSE_BINARY=\"$(git rev-parse --show-toplevel)/target/release/goose\" pnpm dev","handlingStrategy":"validation","validationCode":"// Resolve and stat the override before the app needs it\nimport fs from 'node:fs';\nimport path from 'node:path';\n\nfunction validateGooseBinaryEnv(): string {\n  const raw = process.env.GOOSE_BINARY;\n  if (!raw) throw new Error('GOOSE_BINARY not set');\n  const resolved = path.resolve(raw);\n  if (!fs.existsSync(resolved) || !fs.statSync(resolved).isFile()) {\n    throw new Error(`GOOSE_BINARY does not point to a file: ${raw} (resolves to ${resolved})`);\n  }\n  return resolved;\n}","typeGuard":"function isExecutableFile(p: string): boolean {\n  try {\n    return fs.statSync(p).isFile();\n  } catch {\n    return false;\n  }\n}","tryCatchPattern":"try {\n  const binaryPath = findGooseBinaryPath({ isPackaged: false });\n} catch (error) {\n  if (/Invalid GOOSE_BINARY path/.test(String(error))) {\n    // Build once, then retry with an absolute path derived from the repo root\n    throw new Error(`${error.message} — run 'cargo build --release' and set an absolute GOOSE_BINARY`);\n  }\n  throw error;\n}","preventionTips":["Always set GOOSE_BINARY to an absolute path (e.g. via $(git rev-parse --show-toplevel)).","Build the binary before launching the Electron dev app.","Remember path.resolve uses the Electron process cwd, not your shell's cwd."],"tags":["environment","path","build","development"],"backgroundTag":null,"analyzedSha":"3810898a7447ec3299be72e223d3570a7aabf0ab","analyzedAt":"2026-08-16T10:14:26.282Z","schemaVersion":2},"datasetVersion":"2026-08-16T13:17:31.715Z"}