Skip to content

fix: Windows spawn EINVAL with paths containing spaces#62

Open
matiassanchez12 wants to merge 1 commit into
bevibing:mainfrom
matiassanchez12:main
Open

fix: Windows spawn EINVAL with paths containing spaces#62
matiassanchez12 wants to merge 1 commit into
bevibing:mainfrom
matiassanchez12:main

Conversation

@matiassanchez12

@matiassanchez12 matiassanchez12 commented May 26, 2026

Copy link
Copy Markdown

Summary

Related Issue

Closes #

Type of Change

  • Bug fix (non-breaking change that fixes an issue)
  • New feature (non-breaking change that adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to change)
  • Documentation update
  • Refactoring (no functional changes)

Changes Made

Testing

  • I have tested this locally
  • I have added/updated tests (if applicable)
  • All existing tests pass (npm test)

Checklist

  • My code follows the existing code style
  • I have not included version bumps (maintainer handles versioning)
  • I have updated documentation if needed
  • This PR focuses on a single feature/fix

Screenshots (if applicable)

Additional Notes

Fixes Windows spawn EINVAL errors when OpenCode is installed in paths with spaces (e.g. C:\Program Files).

Errors fixed:

  1. `spawn EINVAL` - spawn() without `shell: true` cannot execute .cmd shims on Windows
  2. `"C:\Program" is not recognized as an internal or external command` - `shell: true` without quoting paths with spaces causes Windows to split the command

cwd: projectPath,
env,
stdio: ["inherit", "pipe", "pipe"],
shell: true,

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Enabling shell: true unconditionally makes this fix platform-wide. The Windows command is quoted above, but POSIX paths returned by resolveOpencodeCommand are now passed through /bin/sh unquoted and can still be split if they contain spaces. Please keep direct spawn(command, args, ...) behavior on POSIX and only enable shell mode for Windows, with a regression test for a Windows command path containing spaces.

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

This sounds logic. I will do commit with the fix soon!

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.

2 participants