Skip to content

cbm_find_cli() fails on Windows: wrong PATH delimiter and S_IXUSR check #159

@slvnlrt

Description

@slvnlrt

Bug

cbm_find_cli() never finds OpenCode or Aider on Windows because:

  1. It uses : as PATH delimiter — Windows uses ;. This splits C:\Users\... at the drive letter colon, producing garbage paths.
  2. S_IXUSR check always fails — stat() on Windows does not set Unix permission bits. npm installs CLI shims as extensionless files (e.g. opencode, not opencode.exe), which stat() finds but the S_IXUSR check rejects.

This was noted in commit 5ca369f3 which skips OpenCode/Aider in Windows smoke tests rather than fixing detection.

Reproduction

# Install opencode
npm install -g opencode-ai

# Verify it's on PATH
where.exe opencode
# C:\Users\<user>\AppData\Roaming\npm\opencode
# C:\Users\<user>\AppData\Roaming\npm\opencode.cmd

# Run install
codebase-memory-mcp install -y
# Detected agents: Claude-Code Gemini-CLI Zed Antigravity
# (OpenCode is missing)

Root cause

In src/cli/cli.c, cbm_find_cli():

char *dir = strtok_r(path_copy, ":", &saveptr);
// ...
if (stat(buf, &st) == 0 && (st.st_mode & S_IXUSR)) {
  1. : delimiter splits C:\Users\... at the drive letter colon → garbage paths
  2. S_IXUSR is a Unix concept — stat() on Windows never sets this bit

Suggested fix

#ifdef _WIN32
const char *path_sep = ";";
#else
const char *path_sep = ":";
#endif
char *dir = strtok_r(path_copy, path_sep, &saveptr);
// ...
#ifdef _WIN32
if (stat(buf, &st) == 0) {           // file exists is enough
#else
if (stat(buf, &st) == 0 && (st.st_mode & S_IXUSR)) {
#endif

Environment

  • Windows 11 Pro
  • codebase-memory-mcp 0.5.7
  • OpenCode installed via npm (opencode-ai)

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't workingeditor/integrationEditor compatibility and CLI integration

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions