oven-sh/bun · error · Error
Failed to download Packer: ${response.status}
Error message
Failed to download Packer: ${response.status} What it means
Thrown by scripts/machine.mjs while installing HashiCorp Packer for Windows Azure image builds. The script fetches a pinned release zip (packer_1.15.0_<platform>_<arch>.zip) from releases.hashicorp.com and this error means the HTTP response completed but response.ok was false. The numeric status is embedded so you can tell a 404 (bad URL) from a 5xx/proxy failure.
Source
Thrown at scripts/machine.mjs:1346
}
// Check if we have a local copy
const localPacker = join(tmpdir(), "packer");
if (existsSync(localPacker)) {
return localPacker;
}
// Download Packer
const version = "1.15.0";
const platform = process.platform === "win32" ? "windows" : process.platform;
const packerArch = process.arch === "arm64" ? "arm64" : "amd64";
const url = `https://releases.hashicorp.com/packer/${version}/packer_${version}_${platform}_${packerArch}.zip`;
console.log(`[packer] Downloading Packer ${version}...`);
const zipPath = join(tmpdir(), "packer.zip");
const response = await fetch(url);
if (!response.ok) throw new Error(`Failed to download Packer: ${response.status}`);
const buffer = Buffer.from(await response.arrayBuffer());
writeFileSync(zipPath, buffer);
// Extract
await spawnSafe(["unzip", "-o", zipPath, "-d", tmpdir()], { stdio: "inherit" });
chmodSync(localPacker, 0o755);
console.log(`[packer] Installed Packer ${version}`);
return localPacker;
}
async function main() {
const { positionals } = parseArgs({
allowPositionals: true,
strict: false,
});
const [command] = positionals;View on GitHub (pinned to 8c5296ac45)
Solutions
- curl -fL the exact URL printed by the `[packer] Downloading` log line to see the real status code
- Verify the runner maps to a published release: process.platform win32→'windows', arch arm64→'arm64' else 'amd64'; check the release listing for 1.15.0
- Fix network/proxy (HTTPS_PROXY/HTTP_PROXY) or re-run — the CDN is occasionally transient
- Pre-install Packer on PATH or place it at the local cache path so the function returns before reaching the download
Example fix
// before
const response = await fetch(url);
if (!response.ok) throw new Error(`Failed to download Packer: ${response.status}`);
// after — retry transient failures, fail fast on 4xx
let response: Response | undefined;
for (let attempt = 0; attempt < 3 && !response?.ok; attempt++) {
response = await fetch(url);
if (response.status >= 500 && attempt < 2) continue;
}
if (!response?.ok) throw new Error(`Failed to download Packer: ${response.status}`); Defensive patterns
Strategy: retry
Validate before calling
import { existsSync } from "node:fs";
import { localPacker } from "./machine.mjs"; // or replicate its path
// Skip the download branch entirely when Packer is already usable.
if (!existsSync(localPacker)) {
const url = "https://releases.hashicorp.com/packer/1.15.0/packer_1.15.0_linux_amd64.zip";
const head = await fetch(url, { method: "HEAD" });
if (!head.ok) throw new Error(`Packer release unreachable (HTTP ${head.status}) — fix network or URL`);
} Try / catch
try {
await ensurePacker();
} catch (err) {
if (/Failed to download Packer: (5\d\d|429)/.test(String(err))) {
await sleep(5_000); // simple backoff, then one retry
return ensurePacker();
}
throw err; // 4xx (bad URL/platform) will not heal — rethrow
} Prevention
- Pre-install the pinned Packer version on CI runners or bake it into the image so the download path never runs
- Pin the version only to combinations that exist on releases.hashicorp.com for your runner platform/arch
- CI networks: allowlist releases.hashicorp.com through the proxy
When it happens
Trigger: Running `machine.mjs create-image/publish-image` for Azure + windows when no usable Packer is already installed locally (the download branch only runs then). A 404 happens when the computed platform/arch pair has no published release; 403/5xx happen behind corporate proxies or when the release CDN is flaky.
Common situations: CI runner without outbound internet or with an HTTPS_PROXY that blocks releases.hashicorp.com; the pinned version 1.15.0 lacking a build for the runner's platform (e.g. an unusual arch mapping); transient CDN errors during CI.
Related errors
- [azure] Failed to get public IP for ${vmName}
- Packer template not found: ${templateFile}
- packer build exited with ${signal ? `signal ${signal}` : `co
- Azure secret not found: ${name}
- [azure] Operation poll failed after ${fetchErrors} fetch err
AI-assisted analysis of oven-sh/bun@8c5296ac45 (2026-08-16).
Data as JSON: /api/errors/922ab4f1de1387ee.
Report an issue: GitHub.