Skip to content

fix(win32): fix plugin resolution with createRequire fallback - #14898

Merged
Hona merged 1 commit into
anomalyco:devfrom
Hona:fix/plugin-resolution-bun-install
Feb 24, 2026
Merged

fix(win32): fix plugin resolution with createRequire fallback#14898
Hona merged 1 commit into
anomalyco:devfrom
Hona:fix/plugin-resolution-bun-install

Conversation

@Hona

@HonaHona commented Feb 24, 2026

Copy link
Copy Markdown
Member

Summary

  • Remove 3s sleep after writing package.json in installDependencies — was unnecessary and caused test timeouts.
  • Add createRequire fallback when import.meta.resolve fails for plugins in freshly created node_modulesimport.meta.resolve sometimes can't find packages that were just installed on Windows.
  • Use static expected path in config test assertion instead of mirroring production fallback logic.

Fixes 4 Windows unit test failures. Split out from #14742.

CopilotAI review requested due to automatic review settings February 24, 2026 12:07

CopilotAI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR fixes Windows-specific test failures by improving plugin resolution reliability and bun install stability in CI environments.

Changes:

  • Removed unnecessary 3-second sleep after writing package.json that caused test timeouts
  • Added --no-cache flag to bun install in CI and E2E environments to prevent concurrent global cache lock contention
  • Implemented createRequire fallback for plugin resolution when import.meta.resolve fails on Windows with freshly created node_modules
  • Mirrored the createRequire fallback logic in config tests

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 1 comment.

FileDescription
packages/opencode/src/config/config.tsAdded createRequire import and fallback logic for plugin resolution; removed 3s sleep; expanded --no-cache conditions to include CI and E2E environments
packages/opencode/test/config/config.test.tsAdded createRequire fallback in test to mirror production behavior for Windows compatibility
Comments suppressed due to low confidence (2)

packages/opencode/src/config/config.ts:3

  • The fileURLToPath import is not used anywhere in this file. Consider removing it to keep imports clean.
import { pathToFileURL, fileURLToPath } from "url"

packages/opencode/test/config/config.test.ts:697

  • For consistency with the production code in config.ts (which imports createRequire at the top), consider importing createRequire at the top of the test file instead of using a dynamic import. This would also match the pattern used for other imports like pathToFileURL.
 const { createRequire } = await import("module")

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

} catch (e) {
// Fallback for Windows where dynamically created node_modules aren't immediately available to import.meta.resolve
const { createRequire } = await import("module")
const require = createRequire(tmp.path + "/")

CopilotAIFeb 24, 2026

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Inconsistency with production code: The test passes tmp.path + "/" to createRequire, but the production code in config.ts line 1340 passes options.path (the full path to opencode.json file). For consistency and to accurately test the production behavior, this should be createRequire(path.join(tmp.path, "opencode.json")). Additionally, using string concatenation with "/" could cause issues on Windows where paths use backslashes.

Suggested change
constrequire=createRequire(tmp.path+"/")
constrequire=createRequire(path.join(tmp.path,"opencode.json"))

Copilot uses AI. Check for mistakes.
@Hona
Honaforce-pushed the fix/plugin-resolution-bun-install branch from 376689a to 7db0adaCompareFebruary 24, 2026 12:14
@Hona
Honaforce-pushed the fix/plugin-resolution-bun-install branch from 7db0ada to 5a066dcCompareFebruary 24, 2026 12:16
@HonaHona changed the title fix(win32): fix plugin resolution and bun install reliabilityfix(win32): fix plugin resolution with createRequire fallbackFeb 24, 2026
@Hona
Hona merged commit 1af3e9e into anomalyco:devFeb 24, 2026
8 of 10 checks passed
lanej pushed a commit to lanej/opencode that referenced this pull request Feb 24, 2026
kcelia pushed a commit to concrete-security/private-opencode that referenced this pull request Feb 25, 2026
jonathanmiddleton pushed a commit to jonathanmiddleton/opencode that referenced this pull request Mar 10, 2026
xywsxp pushed a commit to xywsxp/opencode that referenced this pull request Apr 24, 2026
Rwanbt pushed a commit to Rwanbt/unifia that referenced this pull request May 5, 2026
AIALRA-0 pushed a commit to AIALRA-0/opencode-turn-engine that referenced this pull request Jun 10, 2026
AIALRA-0 pushed a commit to AIALRA-0/opencode-turn-engine that referenced this pull request Jun 10, 2026
avion23 pushed a commit to avion23/opencode that referenced this pull request Jun 10, 2026
Sign up for freeto join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants

@Hona