Skip to content

Local code intelligence for developers and AI agents. Connect code, docs and infrastructure in a persistent graph, with CBM Lens, MCP tools, agent integrations and change-aware test selection.

fix(cli): forward CBM_RUNTIME_DIR in the generated Codex configuration (#1664)

Martin Vogel20ad3e5b8984
diff --git a/src/cli/cli.c b/src/cli/cli.c
index a3109bdd3..1f850de8f 100644
--- a/src/cli/cli.c
+++ b/src/cli/cli.c
@@ -3452,14 +3452,21 @@ int cbm_upsert_codex_mcp(const char *binary_path, const char *config_path) {
* handshake closes during initialization, so Codex exposes no cbm tools at
* all.
*
- * The name is listed unconditionally rather than only when the variable is
+ * The names are listed unconditionally rather than only when a variable is
* set at install time: env_vars names variables to FORWARD IF PRESENT, so
- * listing it costs nothing when unset and keeps working for someone who
- * sets it after installing — which install-time detection would silently
- * fail to cover. */
+ * listing them costs nothing when unset and keeps working for someone who
+ * sets one after installing — which install-time detection would silently
+ * fail to cover.
+ *
+ * CBM_RUNTIME_DIR joined the list with #1664: since #1645 it relocates
+ * the daemon rendezvous, so a Codex subprocess that does not receive it
+ * looks for the daemon in the DEFAULT location and never finds it — the
+ * same silent client/daemon split CBM_CACHE_DIR caused. Both names decide
+ * WHICH daemon a process talks to; behavioural knobs stay unforwarded. */
int written = snprintf(block, sizeof(block),
CODEX_CMM_SECTION "\ncommand = \"%s\"\nargs = []\n"
- "env_vars = [\"CBM_CACHE_DIR\"]\n",
+ "env_vars = [\"CBM_CACHE_DIR\", "
+ "\"CBM_RUNTIME_DIR\"]\n",
escaped);
if (written < 0 || (size_t)written >= sizeof(block) ||
cbm_remove_codex_legacy_mcp(config_path) != 0) {
diff --git a/tests/test_cli.c b/tests/test_cli.c
index ce1fc298a..8eda0bb3f 100644
--- a/tests/test_cli.c
+++ b/tests/test_cli.c
@@ -10612,7 +10612,7 @@ TEST(cli_upsert_codex_mcp_fresh) {
* subprocess. Without CBM_CACHE_DIR the spawned server uses the DEFAULT
* cache while the daemon uses the configured one, the two disagree, and the
* handshake closes — Codex then shows no cbm tools at all. */
- ASSERT(strstr(data, "env_vars = [\"CBM_CACHE_DIR\"]") != NULL);
+ ASSERT(strstr(data, "env_vars = [\"CBM_CACHE_DIR\", \"CBM_RUNTIME_DIR\"]") != NULL);
test_rmdir_r(tmpdir);
PASS();