Version
e599df1
Platform
Linux (x64)
Install channel
Built from source
Binary variant
standard
What happened, and what did you expect?
After codebase-memory-mcp install on NixOS, every Claude Code session start showed:
SessionStart:resume [~/.claude/hooks/cbm-session-reminder] failed with non-blocking
status code 127: /bin/sh: line 1: /home/<user>/.claude/hooks/cbm-session-reminder: cannot
execute: required file not found
The hooks installed by codebase-memory-mcp install have #!/bin/bash shebangs. On NixOS, /bin/bash does not exist — only /bin/sh (which is bash, but only via a NixOS-managed symlink). When Claude Code executes the hook, /usr/bin/env searches a stripped PATH that does not include the directory containing bash, so env bash also fails. The fix is to use the absolute path to bash: #!/run/current-system/sw/bin/bash.
Expected: the hooks install with a portable shebang (e.g. #!/usr/bin/env bash) and Claude Code runs hooks with a PATH that includes standard binary locations, or the install script detects the system bash path and uses it directly.
Reproduction
- Install NixOS (any recent release).
/bin/bash does not exist; bash lives at /run/current-system/sw/bin/bash.
- Install
codebase-memory-mcp from the flake (see details) and run codebase-memory-mcp install targeting Claude Code.
- Start a new Claude Code session.
- Observe the
status code 127 error for cbm-session-reminder and cbm-code-discovery-gate.
Workaround applied: replace #!/bin/bash with #!/run/current-system/sw/bin/bash in both hook files.
A more portable fix would be for the install script to detect the system bash path (e.g. $(command -v bash)) and write that into the shebang, or to ensure Claude Code's hook runner provides a PATH that includes standard binary directories.
Details
flake.lock
{
"nodes": {
"codebase-memory-mcp": {
"inputs": {
"nixpkgs": [
"nixpkgs"
]
},
"locked": {
"lastModified": 1781281003,
"narHash": "sha256-jFIZ3+EgNUK3z/6dg0U4idxmp0UHa8Zk79Z36dhE3hg=",
"owner": "DeusData",
"repo": "codebase-memory-mcp",
"rev": "e599df1d563c1e9b0b2fc8c6b12ee85934ade1c5",
"type": "github"
},
"original": {
"owner": "DeusData",
"repo": "codebase-memory-mcp",
"type": "github"
}
},
<more>
flake.nix
<more>
codebase-memory-mcp = {
url = "github:DeusData/codebase-memory-mcp";
inputs.nixpkgs.follows = "nixpkgs";
};
<more>
Logs
/bin/sh: line 1: /home/<user>/.claude/hooks/cbm-session-reminder: cannot execute: required file not found
strace output showing env searching a PATH without any directory containing bash:
execve("/nix/store/.../zplug-2.4.2/share/zplug/bin/bash", ...) = -1 ENOENT
execve("/home/<user>/bin/bash", ...) = -1 ENOENT
execve("/home/<user>/.local/bin/bash", ...) = -1 ENOENT
execve("/run/wrappers/bin/bash", ...) = -1 ENOENT
execve("/home/<user>/.nix-profile/bin/bash", ...) = -1 ENOENT
Project scale (if relevant)
53 nodes / 52 edges (small NixOS config repo)
Confirmations
Version
e599df1
Platform
Linux (x64)
Install channel
Built from source
Binary variant
standard
What happened, and what did you expect?
After
codebase-memory-mcp installon NixOS, every Claude Code session start showed:The hooks installed by
codebase-memory-mcp installhave#!/bin/bashshebangs. On NixOS,/bin/bashdoes not exist — only/bin/sh(which is bash, but only via a NixOS-managed symlink). When Claude Code executes the hook,/usr/bin/envsearches a strippedPATHthat does not include the directory containingbash, soenv bashalso fails. The fix is to use the absolute path to bash:#!/run/current-system/sw/bin/bash.Expected: the hooks install with a portable shebang (e.g.
#!/usr/bin/env bash) and Claude Code runs hooks with aPATHthat includes standard binary locations, or the install script detects the system bash path and uses it directly.Reproduction
/bin/bashdoes not exist; bash lives at/run/current-system/sw/bin/bash.codebase-memory-mcpfrom the flake (see details) and runcodebase-memory-mcp installtargeting Claude Code.status code 127error forcbm-session-reminderandcbm-code-discovery-gate.Workaround applied: replace
#!/bin/bashwith#!/run/current-system/sw/bin/bashin both hook files.A more portable fix would be for the install script to detect the system bash path (e.g.
$(command -v bash)) and write that into the shebang, or to ensure Claude Code's hook runner provides aPATHthat includes standard binary directories.Details
flake.lock
flake.nix
Logs
straceoutput showingenvsearching aPATHwithout any directory containingbash:Project scale (if relevant)
53 nodes / 52 edges (small NixOS config repo)
Confirmations