Skip to content

fix(cli): detect actual binary path at runtime in install command#160

Open
slvnlrt wants to merge 1 commit intoDeusData:mainfrom
slvnlrt:fix/windows-install-self-path
Open

fix(cli): detect actual binary path at runtime in install command#160
slvnlrt wants to merge 1 commit intoDeusData:mainfrom
slvnlrt:fix/windows-install-self-path

Conversation

@slvnlrt
Copy link
Copy Markdown

@slvnlrt slvnlrt commented Mar 27, 2026

Summary

cbm_cmd_install() hardcodes ~/.local/bin/codebase-memory-mcp.exe as the binary path written into agent MCP configs. When installed via install.ps1 (which targets $LOCALAPPDATA/Programs/), all agent configs point to a non-existent path — MCP fails for every agent.

Fixes #158

Change

Single file: src/cli/cli.c

Use runtime binary path detection — the same pattern already in http_server.c:index_thread_fn() (line 594):

  • Windows: GetModuleFileNameA() + cbm_normalize_path_sep()
  • macOS: _NSGetExecutablePath()
  • Linux: readlink("/proc/self/exe")
  • Fallback: ~/.local/bin/ (preserves current behavior if detection fails)

Added #include <mach-o/dyld.h> for macOS.

Testing

Runtime path detection is hard to unit-test (it depends on the actual binary location). The existing smoke tests (smoke-test.sh) cover install -y end-to-end and will verify the configs point to a valid path.

Manual verification on Windows:

# Before fix: ~/.claude/.mcp.json → "C:/Users/<user>/.local/bin/codebase-memory-mcp.exe" (does not exist)
# After fix:  ~/.claude/.mcp.json → "C:/Users/<user>/AppData/Local/Programs/codebase-memory-mcp/codebase-memory-mcp.exe" (exists)

@DeusData DeusData added bug Something isn't working editor/integration Editor compatibility and CLI integration labels Mar 27, 2026
install.ps1 places the binary in $LOCALAPPDATA/Programs/ but
cbm_cmd_install() hardcoded ~/.local/bin/ when writing agent MCP
configs, causing MCP to fail on Windows.

Use GetModuleFileNameA (Win), _NSGetExecutablePath (macOS), or
readlink /proc/self/exe (Linux) — same pattern as
http_server.c:index_thread_fn(). Falls back to ~/.local/bin/ if
runtime detection fails.

Fixes DeusData#158
@slvnlrt slvnlrt force-pushed the fix/windows-install-self-path branch from dd0ed38 to 6db11d6 Compare March 27, 2026 14:26
@slvnlrt slvnlrt marked this pull request as ready for review March 27, 2026 14:29
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working editor/integration Editor compatibility and CLI integration

Projects

None yet

Development

Successfully merging this pull request may close these issues.

install -y writes wrong binary path on Windows (hardcoded ~/.local/bin/ vs actual location)

2 participants