aaif-goose/goose · error

Invalid GOOSE_BINARY path: ${pathFromEnv} (pwd is ${process.

Error message

Invalid GOOSE_BINARY path: ${pathFromEnv} (pwd is ${process.cwd()})

What it means

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.

Source

Thrown at ui/desktop/src/gooseServe.ts:77

    return fs.existsSync(candidate) && fs.statSync(candidate).isFile();
  } catch {
    return false;
  }
};

export const findGooseBinaryPath = (options: FindGooseBinaryOptions = {}): string => {
  const { isPackaged = false, resourcesPath } = options;
  const pathFromEnv = process.env.GOOSE_BINARY;
  if (pathFromEnv) {
    if (isPackaged) {
      throw new Error('GOOSE_BINARY is only supported in development builds');
    }

    const resolvedPath = path.resolve(pathFromEnv);
    if (existingFile(resolvedPath)) {
      return resolvedPath;
    }
    throw new Error(`Invalid GOOSE_BINARY path: ${pathFromEnv} (pwd is ${process.cwd()})`);
  }

  const binaryName = process.platform === 'win32' ? 'goose.exe' : 'goose';
  const possiblePaths: string[] = [];

  if (isPackaged && resourcesPath) {
    possiblePaths.push(path.join(resourcesPath, 'bin', binaryName));
    possiblePaths.push(path.join(resourcesPath, binaryName));
  } else {
    possiblePaths.push(
      path.join(process.cwd(), 'src', 'bin', binaryName),
      path.join(process.cwd(), '..', '..', 'target', 'release', binaryName),
      path.join(process.cwd(), '..', '..', 'target', 'debug', binaryName)
    );
  }

  for (const candidate of possiblePaths) {
    if (existingFile(candidate)) {

View on GitHub (pinned to 3810898a74)

Solutions

  1. Use an absolute path: export GOOSE_BINARY="$PWD/target/release/goose" from the repo root after building.
  2. Confirm the file exists at the resolved location: ls the path shown after '(pwd is ...)'.
  3. Build first: cargo build --release (or just release-binary) so target/release/goose exists.
  4. On Windows include the .exe extension.

Example fix

# before
GOOSE_BINARY="../target/release/goose" pnpm dev   # fails when cwd differs

# after
GOOSE_BINARY="$(git rev-parse --show-toplevel)/target/release/goose" pnpm dev
Defensive patterns

Strategy: validation

Validate before calling

// Resolve and stat the override before the app needs it
import fs from 'node:fs';
import path from 'node:path';

function validateGooseBinaryEnv(): string {
  const raw = process.env.GOOSE_BINARY;
  if (!raw) throw new Error('GOOSE_BINARY not set');
  const resolved = path.resolve(raw);
  if (!fs.existsSync(resolved) || !fs.statSync(resolved).isFile()) {
    throw new Error(`GOOSE_BINARY does not point to a file: ${raw} (resolves to ${resolved})`);
  }
  return resolved;
}

Type guard

function isExecutableFile(p: string): boolean {
  try {
    return fs.statSync(p).isFile();
  } catch {
    return false;
  }
}

Try / catch

try {
  const binaryPath = findGooseBinaryPath({ isPackaged: false });
} catch (error) {
  if (/Invalid GOOSE_BINARY path/.test(String(error))) {
    // Build once, then retry with an absolute path derived from the repo root
    throw new Error(`${error.message} — run 'cargo build --release' and set an absolute GOOSE_BINARY`);
  }
  throw error;
}

Prevention

When it happens

Trigger: 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.

Common situations: 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.

Related errors


AI-assisted analysis of aaif-goose/goose@3810898a74 (2026-08-16). Data as JSON: /api/errors/917153c7012daf28. Report an issue: GitHub.