ruvnet / ruvnet/ruflo

Windows: ruflo-core hooks still fail with '/bin/bash: /bin/bash: cannot execute binary file' in 0.2.2 (regression of #2132)

Open Beginner friendly
#2,272 0 comments 0 reactions 0 assignees View on GitHub
Dominant language
TypeScript
Stars
72.7k
Forks
8.6k
Avg merge
2d 23h
Merged PRs (30d)
83

Description

## Relation to prior issues

This appears to be a **regression / incomplete fix** of the Windows hook problem already reported and closed:

- #2132 / #2133 / #2134 — "Plugin hooks use /bin/bash and POSIX-only pipelines — broken on Windows" (CLOSED)
- #2155 — "fix(plugins/ruflo-core/hooks): 3 unwrapped .sh invocations cause exit-126 on Windows (#2132 follow-up)" (CLOSED)
- #680 — "Hook error on windows persisting" (still OPEN)

The fix from those issues kept `hooks/hooks.json` **POSIX-only** (`_platform: posix`) and relied on `ruflo init` writing a Windows `.claude/settings.json` override. But on a fresh plugin install where `ruflo init` was never run (e.g. the plugin is simply enabled in Claude Code), the shipped `hooks.json` is still active and still fails. The default Windows experience is therefore still broken in **0.2.2**. Please consider reopening / shipping the cross-platform `hooks.json` below so the default case works without a manual `ruflo init`.

## Summary

On native Windows, every `ruflo-core` plugin hook fails with:

```
Stop [ruflo-core] failed with non-blocking status code: /bin/bash: /bin/bash: cannot execute binary file
```

This surfaces on **every turn** (the Stop hook is the most visible, but `PreToolUse`, `PostToolUse`, and `PreCompact` are all affected) because `hooks/hooks.json` invokes each hook as `/bin/bash -c '...'`.

## Environment

- OS: Windows 11 (win32)
- Claude Code (plugin host)
- Plugin: `ruflo-core@ruflo` version **0.2.2**
- File: `plugins/ruflo-core/0.2.2/hooks/hooks.json`
- A Git-for-Windows `bash` is on PATH (`/usr/bin/bash`), but `/bin/bash` resolves to a **Windows PE executable**:
```
$ file /bin/bash
/bin/bash: PE32+ executable (console) x86-64 (stripped to external PDB), for MS Windows
```

## Root cause

`hooks/hooks.json` is explicitly marked POSIX-only and hard-codes `/bin/bash -c '...'` for every hook. The file's own `_platform_note` documents the intent: *"On Windows, ruflo init writes a `.claude/settings.json` that overrides these entries with node-based equivalents via `plugins/ruflo-core/scripts/ruflo-hook.cjs`."*

In practice that Windows override is **not** applied (a fresh plugin install / a project that never ran `ruflo init` on Windows keeps the POSIX `hooks.json` active). When Claude Code spawns the hook on Windows, `bash` is handed `/bin/bash` as a *script argument* to execute — and since `/bin/bash` is a binary, bash reports `cannot execute binary file`, yielding the doubled `/bin/bash: /bin/bash:` message.

Notably, the cross-platform Node shim the project already ships — `scripts/ruflo-hook.cjs` — was built for exactly this case (its header comment: *"The bash shim (ruflo-hook.sh) works on Mac/Linux but fails on native Windows (exit 126 — 'cannot execute binary file')."*). The bug is simply that nothing routes Windows hook execution to it by default.

## Steps to reproduce

1. On Windows, enable the `ruflo-core` plugin in Claude Code.
2. Do **not** run `ruflo init` (or run in a project that has no `.claude/settings.json` hook overrides).
3. Trigger any tool call or let the turn end.
4. Observe the Stop-hook error above.

The two `PreCompact` hooks are pure `echo` guidance text run through `/bin/bash`; on Windows they fail the same way. They should either be dropped or re-expressed in a cross-platform way (e.g. `node -e "console.log(...)"`).

The current design only works on Windows if the user runs `ruflo init` *and* Claude Code's settings-hook merge actually suppresses the plugin's own `hooks.json` entries. Plugin hooks and settings hooks generally **both** run, so the POSIX entries keep firing and erroring regardless of the settings override. Making `hooks.json` itself cross-platform removes the failure at the source and keeps the same hook behavior on Mac/Linux (`node` + the shim works identically there).

### Verification

With the patched `hooks.json`, the Stop hook runs cleanly:

```
$ echo '{}' | RUFLO_HOOK_SKIP_NPX=1 node "$CLAUDE_PLUGIN_ROOT/scripts/ruflo-hook.cjs" session-end
$ echo $?
0
```

No `/bin/bash` error; exit 0 as intended.

Contributor guide

Open the contributing guide

Research direction

Start with plugins/ruflo-core/0.2.2/hooks/hooks.json and compare its hook commands with plugins/ruflo-core/scripts/ruflo-hook.cjs, whose header describes the Windows failure. Run the provided Windows verification command with RUFLO_HOOK_SKIP_NPX=1 and confirm the hooks no longer invoke /bin/bash and the Stop hook exits 0.

Written by the indexing model from the issue text.

Assessment

Tech stack
javascript, node.js
Domain
tooling
Issue type
Bug
Difficulty
2/5
Estimated time
1-3 hours
Activity status
Quiet
Clarity
Clearly specified
Newbie friendliness
74/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.