Skip to content

fix: convert import.meta.resolve result to file:// URL for plugins#16558

Closed
abc-lee wants to merge 1 commit intoanomalyco:devfrom
abc-lee:fix-plugin-path-resolve
Closed

fix: convert import.meta.resolve result to file:// URL for plugins#16558
abc-lee wants to merge 1 commit intoanomalyco:devfrom
abc-lee:fix-plugin-path-resolve

Conversation

@abc-lee
Copy link

@abc-lee abc-lee commented Mar 8, 2026

Summary

On Windows, import.meta.resolve() returns a raw filesystem path instead of a file:// URL. This causes the plugin name extraction logic to fail, displaying the full raw path in the UI.

How to Test

  1. On Windows, add a plugin in opencode.json: "plugin": ["oh-my-opencode@latest"]
  2. Start OpenCode and check the plugin list in /status dialog
  3. Before fix: Shows raw path like C:\Users\Username\ or E:\opencode\
  4. After fix: Shows correct plugin name oh-my-opencode @latest

Test Plan

  • Verified fix resolves the issue on Windows
  • Code change is minimal and matches existing require.resolve() fallback pattern
  • CI tests pass

Fixes #16559

On Windows, import.meta.resolve() returns a raw filesystem path like
'E:\path\to\plugin\index.js' instead of a file:// URL. This causes
the plugin name extraction logic to fail, displaying the full path
in the UI instead of the plugin name.

The fix ensures all resolved plugin paths are consistently converted
to file:// URLs, matching the behavior of the require.resolve() fallback.

Fixes: Plugin paths displayed incorrectly on Windows
@github-actions github-actions bot added the needs:compliance This means the issue will auto-close after 2 hours. label Mar 8, 2026
@github-actions
Copy link
Contributor

github-actions bot commented Mar 8, 2026

This PR doesn't fully meet our contributing guidelines and PR template.

What needs to be fixed:

  • PR description is missing required template sections. Please use the PR template.

Please edit this PR description to address the above within 2 hours, or it will be automatically closed.

If you believe this was flagged incorrectly, please let a maintainer know.

@github-actions
Copy link
Contributor

github-actions bot commented Mar 8, 2026

Thanks for your contribution!

This PR doesn't have a linked issue. All PRs must reference an existing issue.

Please:

  1. Open an issue describing the bug/feature (if one doesn't exist)
  2. Add Fixes #<number> or Closes #<number> to this PR description

See CONTRIBUTING.md for details.

@github-actions
Copy link
Contributor

github-actions bot commented Mar 8, 2026

The following comment was made by an LLM, it may be inaccurate:

Based on the search results, here are potential related PRs:

  1. fix(config): avoid dedup collisions for file:// plugins in node_modules #15598 - fix(config): avoid dedup collisions for file:// plugins in node_modules

    • Related because it also deals with file:// URL handling for plugins and deduplication logic
  2. fix(opencode): prevent plugin deduplication collision for index.js entry points #11161 - fix(opencode): prevent plugin deduplication collision for index.js entry points

    • Related because it addresses plugin deduplication issues, which may be impacted by path format inconsistencies

Both PRs appear to address plugin path handling and deduplication issues, which are closely related to the current PR's fix for ensuring consistent file:// URL conversion. These should be reviewed to ensure compatibility and avoid overlapping fixes.

@abc-lee
Copy link
Author

abc-lee commented Mar 8, 2026

CI Failure Analysis

The CI failure is not caused by this PR.

The failing test packages/opencode/test/util/process.test.ts:61 uses /tmp as the working directory:

test("uses cwd when spawning commands", async () => {
  const out = await Process.run(node("process.stdout.write(process.cwd())"), {
    cwd: "/tmp",  // ? This path does not exist on Windows
  })
  expect(out.stdout.toString()).toBe("/tmp")
})

This test fails on Windows because /tmp is a Linux/Unix path that does not exist on Windows. This is a pre-existing issue in the codebase.

My change (in packages/opencode/src/config/config.ts) is unrelated to this test - it only adds a pathToFileURL() conversion for plugin paths.

Suggestion

The test should use a cross-platform temp directory approach:

import { tmpdir } from "os"
// or use the test fixture mentioned in test/AGENTS.md

@github-actions
Copy link
Contributor

github-actions bot commented Mar 8, 2026

This pull request has been automatically closed because it was not updated to meet our contributing guidelines within the 2-hour window.

Feel free to open a new pull request that follows our guidelines.

@github-actions github-actions bot removed the needs:compliance This means the issue will auto-close after 2 hours. label Mar 8, 2026
@github-actions github-actions bot closed this Mar 8, 2026
@abc-lee abc-lee deleted the fix-plugin-path-resolve branch March 8, 2026 15:04
Sign up for free to 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.

fix: Plugin paths displayed incorrectly on Windows

1 participant