Skip to content

[Bug] Windows binary selection picks AVX version on non-AVX CPUs #8744

Closed

Description

@sadnow

Summary

The Windows launcher script (bin/opencode) picks opencode-windows-x64 instead of opencode-windows-x64-baseline on CPUs without AVX support, causing immediate crash on startup.

Environment

  • OS: Windows 11
  • CPU: Intel/AMD without AVX (only SSE4.2)
  • opencode-ai version: 1.1.19-1.1.22 (all affected)
  • Node.js: v22.x

Error

Bun v1.3.6 (d530ed99) Windows x64 (baseline)
CPU: sse42
Features: ... no_avx2 no_avx ...

CPU lacks AVX support. Please consider upgrading to a newer CPU.
panic(main thread): Illegal instruction at address 0x7FF7132980FC
oh no: Bun has crashed.

Root Cause

The launcher script in bin/opencode uses:

const base = "opencode-" + platform + "-" + arch
// ...
for (const entry of entries) {
  if (!entry.startsWith(base)) continue
  // picks first match
}

Both opencode-windows-x64 and opencode-windows-x64-baseline match the pattern opencode-windows-x64. The first match wins, which depends on filesystem ordering (directory enumeration order).

Suggested Fix

Option A: Check AVX support before selecting binary (preferred)

// Detect AVX support and prefer baseline when not available
const hasAvx = checkCpuFeature('avx');
const preferBaseline = !hasAvx;

Option B: Prefer -baseline suffix when on Windows

// Sort entries to prefer baseline on Windows
entries.sort((a, b) => {
  const aBaseline = a.includes('-baseline');
  const bBaseline = b.includes('-baseline');
  // Prefer baseline if no AVX detected
  return preferBaseline ? (bBaseline - aBaseline) : (aBaseline - bBaseline);
});

Option C: Document OPENCODE_BIN_PATH workaround prominently

Workaround

Users can set the OPENCODE_BIN_PATH environment variable to force the baseline binary:

[System.Environment]::SetEnvironmentVariable(
  'OPENCODE_BIN_PATH',
  'C:\Users\<USERNAME>\AppData\Roaming\npm\node_modules\opencode-ai\node_modules\opencode-windows-x64-baseline\bin\opencode.exe',
  'User'
)

Impact

This affects all Windows users with older CPUs that lack AVX support (pre-2011 Intel, pre-2012 AMD). The crash occurs immediately on startup before any meaningful error message can be displayed, making it difficult to diagnose.

References

Activity

  1. github-actions commented on Jan 15, 2026

    @github-actions
    Contributor

    This issue might be a duplicate of existing issues. Please check:

    Feel free to ignore if none of these address your specific case.

  2. shaunmorris commented on Feb 5, 2026

    @shaunmorris

    This also affects linux users

  3. github-actions commented on Apr 7, 2026

    @github-actions
    Contributor

    To stay organized issues are automatically closed after 90 days of no activity. If the issue is still relevant please open a new one.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions