Skip to content

OpenCode plugin fails to load in 4.8.4: "path must be a string or a file descriptor" (fixed at HEAD, needs release) #671

Description

@UnoSee

Problem

Installing @dietrichgebert/ponytail as an OpenCode plugin per the README:

{ "plugin": ["@dietrichgebert/ponytail"] }

fails at startup with:

ERROR failed to load plugin path=@dietrichgebert/ponytail error="path must be a string or a file descriptor"

Reproduced on opencode 1.18.11, ponytail 4.8.4 (npm latest), Linux x64, node 26 / bundled bun.

Root cause

.opencode/plugins/ponytail.mjs in 4.8.4 exports parseCommandFile as a named export alongside the default export:

export function parseCommandFile(filePath) { ... }   // line 45
export default async ({ client } = {}) => { ... }

OpenCode's legacy plugin loader (packages/opencode/src/plugin/index.ts, getLegacyPlugins) treats every exported function as a plugin instance and invokes each with the plugin input object:

for (const entry of Object.values(mod)) {
  ...
  const plugin = getServerPlugin(entry)
  if (!plugin) throw new TypeError("Plugin export is not a function")
  result.push(plugin)
}

So opencode calls parseCommandFile(pluginInput)fs.readFileSync(undefined, 'utf8')TypeError [ERR_INVALID_ARG_TYPE]: path must be a string or a file descriptor.

Already fixed at HEAD

The fix is on main — the parser was moved to .opencode/plugins/ponytail-frontmatter.cjs and the test comment in tests/opencode-plugin.test.js documents exactly this crash. It just isn't on npm yet (4.8.4 published 2026-06-29 predates it).

Request

Publish 4.8.5 (or 4.9.0) so { "plugin": ["@dietrichgebert/ponytail"] } works from npm.

Workaround (for anyone hitting this now)

Vendor the fixed files locally and point opencode at the file path:

mkdir -p ~/.config/opencode/plugins/ponytail/.opencode/plugins
cd ~/.config/opencode/plugins/ponytail
curl -sL https://raw.githubusercontent.com/DietrichGebert/ponytail/main/.opencode/plugins/ponytail.mjs -o .opencode/plugins/ponytail.mjs
curl -sL https://raw.githubusercontent.com/DietrichGebert/ponytail/main/.opencode/plugins/ponytail-frontmatter.cjs -o .opencode/plugins/ponytail-frontmatter.cjs
cp -r $(npm root -g 2>/dev/null || echo ~/.config/opencode/node_modules)/@dietrichgebert/ponytail/hooks .
cp -r ~/.config/opencode/node_modules/@dietrichgebert/ponytail/skills .
cp -r ~/.config/opencode/node_modules/@dietrichgebert/ponytail/.opencode/command .opencode/command

The directory layout must mirror the npm package (../../hooks resolves from .opencode/plugins/ up to the package root — symlinks do not work through createRequire, copy the dirs).

{ "plugin": ["./plugins/ponytail/.opencode/plugins/ponytail.mjs"] }

Verified: plugin loads, /ponytail ultra registers and persists mode, system prompt injection works.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions