can1357/oh-my-pi · error · Error

Could not create /opt/omp

Error message

Could not create /opt/omp: ${mkdir.stderr.trim()}

What it means

installAgent provisions the omp binary inside a trial VM. Before copying the binary it runs `mkdir -p /opt/omp` via vm.exec; a non-zero exit code means the guest could not create the install directory, so this error is thrown with the VM's captured stderr appended for diagnosis.

Solutions

  1. Read the stderr in the message to identify the guest-side cause
  2. Verify the VM is running and vm.exec can reach it (run a trivial command like `true`)
  3. Check that the guest root filesystem is writable and not full (df -h, touch a file in /)
  4. Ensure /opt/omp does not exist as a regular file or symlink in the VM image
  5. Rebuild or restart the trial VM from a clean image

Example fix

// before (broken image: /opt/omp is a file)
const mkdir = await vm.exec("mkdir -p /opt/omp");
// after: pre-clean the image or guard in provisioning
await vm.exec("rm -f /opt/omp && mkdir -p /opt/omp");
Defensive patterns

Strategy: validation

Validate before calling

const probe = await vm.exec("mkdir -p /opt/omp && test -w /opt/omp");
if (probe.exitCode !== 0) throw new Error(`VM /opt not writable: ${probe.stderr.trim()}`);

Try / catch

try {
  await installAgent(vm, binaries, gateway);
} catch (err) {
  if (String(err.message).includes("Could not create /opt/omp")) {
    // inspect err.message stderr, reprovision VM
  }
  throw err;
}

Prevention

When it happens

Trigger: vm.exec("mkdir -p /opt/omp") returns a non-zero exitCode — e.g. the guest filesystem is read-only, /opt/omp exists as a non-directory, the VM is booted into recovery/rescue mode, or the exec transport itself fails and surfaces a shell error.

Common situations: Trial VM images mounted read-only or with a full root disk; a broken snapshot where /opt/omp is a stale file; ssh/exec into the VM failing so stderr carries 'connection refused' style text; hypervisor misconfiguration preventing boot.

Related errors


AI-assisted analysis of can1357/oh-my-pi@9690622007 (2026-08-31). Data as JSON: /api/errors/d54df9d2f31bdf49. Report an issue: GitHub.

Appendix: source

Thrown at packages/metaharness/src/tb/agent.ts:95

			if (!(await Bun.file(source).exists())) throw new Error(`Binary build did not produce ${source}`);
			await Bun.write(destination, Bun.file(source));
			await fs.chmod(destination, 0o755);
		}
	}

	const binaries: AgentBinaries = { version: manifest.version };
	for (const arch of arches) binaries[arch] = cached[arch];
	return binaries;
}

/** Install omp and gateway-only configuration into one running trial microVM. */
export async function installAgent(vm: TrialVm, binaries: AgentBinaries, gateway: GatewayConfig): Promise<string> {
	const binary = binaries[vm.arch];
	if (!binary) throw new Error(`No omp binary available for guest architecture ${vm.arch}`);

	const entrypoint = "/opt/omp/omp";
	const mkdir = await vm.exec("mkdir -p /opt/omp");
	if (mkdir.exitCode !== 0) throw new Error(`Could not create /opt/omp: ${mkdir.stderr.trim()}`);
	await vm.copyTo(binary, entrypoint);
	const chmod = await vm.exec(`chmod 755 ${shellQuote(entrypoint)}`);
	if (chmod.exitCode !== 0) throw new Error(`Could not make omp executable: ${chmod.stderr.trim()}`);
	const warmup = await vm.exec(`${shellQuote(entrypoint)} --version`);
	if (warmup.exitCode !== 0) throw new Error(`omp --version failed: ${warmup.stderr.trim()}`);

	const providers = [...new Set(gateway.providers)];
	const modelLines = ["# Generated by metaharness — auth via host pm2 gateway.", "providers:"];
	for (const provider of providers) {
		modelLines.push(`  ${provider}:`);
		modelLines.push(`    baseUrl: ${gateway.url}`);
		modelLines.push("    auth: oauth");
		modelLines.push("    transport: pi-native");
		modelLines.push(`    apiKey: ${gateway.token}`);
	}
	const modelsYaml = `${modelLines.join("\n")}\n`;
	const configYaml = `providers:
  openrouterVariant: ${gateway.openrouterVariant}

View on GitHub (pinned to 9690622007)