Skip to content

[BUG] Plugin git+https:// URL fails to install on Windows due to invalid characters in cache path #21126

Description

@razllivan

Bug Description

When installing a plugin from a git URL (e.g., superpowers@git+https://github.com/obra/superpowers.git), opencode fails on Windows because it uses the raw URL as a directory name in the cache path.

Error

ENOENT: no such file or directory, mkdir 'C:\Users\Ivan\.cache\opencode\packages\superpowers@git+https:\github.com\obra\superpowers.git'

Root Cause

The plugin installer constructs the cache directory path by appending the raw package specifier (e.g., superpowers@git+https://github.com/obra/superpowers.git) directly to the packages cache directory. On Windows, the : character and path separators from the URL are invalid in file/directory names, causing mkdir to fail.

The problematic path transforms https:// into https:\ (backslash due to Windows path normalization), which contains a colon — a forbidden character in Windows filenames.

Reproduction Steps

  1. On Windows, add a git-based plugin to opencode config:
    {
      "plugins": ["superpowers@git+https://github.com/obra/superpowers.git"]
    }
  2. Run opencode run --print-logs "hello"
  3. Observe the ENOENT error during plugin installation

Expected Behavior

The plugin should install successfully. The cache directory name should be derived from a URL-safe encoding (e.g., URL-encoding, hashing, or stripping invalid characters) of the git URL.

Actual Behavior

Installation fails with ENOENT because the cache directory path contains Windows-invalid characters (:).

Environment

Field Value
opencode 1.3.15
Node.js v22.22.2
npm 10.9.7
OS Windows 11 Pro
Shell Git Bash, Powershell, CMD

Log Excerpt

INFO  service=plugin path=superpowers@git+https://github.com/obra/superpowers.git loading plugin
INFO  service=npm pkg=superpowers@git+https://github.com/obra/superpowers.git installing package
ERROR service=plugin pkg=superpowers version=git+https://github.com/obra/superpowers.git error=ENOENT: no such file or directory, mkdir 'C:\Users\Ivan\.cache\opencode\packages\superpowers@git+https:\github.com\obra\superpowers.git' failed to install plugin

Suggested Fix

When constructing the cache directory name for git-based plugins, sanitize the URL by either:

  1. Hashing the URL (e.g., SHA-256 or MD5) to produce a safe directory name
  2. URL-encoding or replacing invalid characters (:, /, <, >, |, ?, *) with safe alternatives
  3. Using a combination of package name prefix + hash suffix for readability

This would also prevent similar issues with other URL-based package specifiers on Windows.

Metadata

Metadata

Assignees

Labels

coreAnything pertaining to core functionality of the application (opencode server stuff)windows

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions