Skip to content

fix: Add Windows platform detection to bash tool#1

Open
kevinkre wants to merge 1 commit intomainfrom
windows-bash-fix
Open

fix: Add Windows platform detection to bash tool#1
kevinkre wants to merge 1 commit intomainfrom
windows-bash-fix

Conversation

@kevinkre
Copy link
Owner

Problem

The cipher bash tool had hardcoded /bin/bash paths that don't exist on Windows, causing ENOENT (Error: No Entry) failures when running as MCP server on Windows.

Root Cause

The bash tool was using Unix-specific absolute paths without checking the operating system. Windows has cmd.exe and powershell.exe, but no /bin/bash directory.

Solution

Added OS detection using the platform module to select the appropriate shell:

  • Windows: Uses cmd.exe with args ['/c']
  • Unix/Linux/Mac: Uses /bin/bash with args ['-c']

Changes Made

Modified: src/core/brain/tools/definitions/system/bash.ts

  1. Imported platform from the os module
  2. Created getShellCommand() helper function that returns:
    • Windows: { shell: 'cmd.exe', args: ['/c'] }
    • Unix: { shell: '/bin/bash', args: ['-c'] }
  3. Updated two execution points:
    • BashSession.initialize() - Uses platform-appropriate shell
    • executeBashCommand() - Uses platform-appropriate shell

Testing

  • ✅ Builds successfully on Windows
  • ✅ Works with PowerShell and CMD
  • ✅ Backwards compatible with Unix systems
  • ✅ No breaking changes to existing Unix behavior

Scope

This is a minimal, surgical fix that:

  • Only affects the bash tool
  • Maintains backwards compatibility
  • Solves Windows compatibility without affecting other tools
  • Enables Windows users (like Claude Desktop users) to use cipher MCP server

- Import platform module for OS detection
- Create getShellCommand() helper for platform-specific shell selection
- Use cmd.exe on Windows, /bin/bash on Unix
- Update BashSession.initialize() and executeBashCommand()
- Maintains backwards compatibility with Unix systems
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.

1 participant