Skip to content

fix: honor LLM_BASE_URL / EMBEDDING_BASE_URL env-var overrides in bootstrap-local#17

Open
djravine wants to merge 2 commits into
bradwmorris:mainfrom
intellipharm-pty-ltd:fix/base-url-env-overrides
Open

fix: honor LLM_BASE_URL / EMBEDDING_BASE_URL env-var overrides in bootstrap-local#17
djravine wants to merge 2 commits into
bradwmorris:mainfrom
intellipharm-pty-ltd:fix/base-url-env-overrides

Conversation

@djravine

Copy link
Copy Markdown

Closes #16.

Summary

scripts/dev/bootstrap-local.mjs writes hardcoded LLM_BASE_URL / EMBEDDING_BASE_URL values to .env.local regardless of any process.env overrides — ensureEnvValue(key, value) never consults the environment.

This is a latent bug on main today (nothing currently sets those env vars at install time), but the in-flight #15 (one-line install scripts) is about to surface it: its --llm-port / --embedding-port flags propagate into the reachability check but get silently overwritten downstream when bootstrap-local lands its hardcoded defaults.

Change

Four lines in bootstrap-local.mjs — wrap the LLM_BASE_URL / EMBEDDING_BASE_URL calls in both the qwen-local and llama-cpp branches with process.env.X || '<default>':

ensureEnvValue('LLM_BASE_URL', process.env.LLM_BASE_URL || 'http://127.0.0.1:11434/v1');  // qwen-local
ensureEnvValue('EMBEDDING_BASE_URL', process.env.EMBEDDING_BASE_URL || 'http://127.0.0.1:11434/v1');
ensureEnvValue('LLM_BASE_URL', process.env.LLM_BASE_URL || 'http://127.0.0.1:8080/v1');   // llama-cpp
ensureEnvValue('EMBEDDING_BASE_URL', process.env.EMBEDDING_BASE_URL || 'http://127.0.0.1:8081/v1');

The openai branch needs no change — it doesn't write base URLs (OpenAI uses the SDK default).

The qwen-local branch is updated for defensive symmetry. Nothing sets those env vars at install time today, but mirroring the override pattern future-proofs against e.g. pointing Ollama at a non-default host and keeps the behaviour consistent across local-LLM profiles.

Verification

Ran end-to-end in a clean ubuntu:24.04 container against this branch's working tree:

== Resulting .env.local (BASE_URL lines) ==
LLM_BASE_URL=http://127.0.0.1:9090/v1
EMBEDDING_BASE_URL=http://127.0.0.1:9091/v1

== Assertions ==
  PASS: both BASE_URL env vars honored

Sequence: apt bootstrap → nvm + Node 20 → rsync working tree → npm installLLM_BASE_URL=http://127.0.0.1:9090/v1 EMBEDDING_BASE_URL=http://127.0.0.1:9091/v1 npm run setup:local -- --profile llama-cpp → grep .env.local for the BASE_URL lines.

Without the fix the same flow produces the hardcoded 8080/8081 defaults — confirmed earlier when the bug was originally identified.

Follow-up

Once this merges, the llama-cpp-with-mock-servers scenario in scripts/install-tests/linux-edge-cases.sh (introduced by #15) can be extended to additionally assert that .env.local ends up with the custom URLs — making it a full end-to-end regression guard for both the install.sh env-var passing and this bootstrap-local override path. The scenario currently ships with an inline LIMITATION: comment pointing at #16 explaining the deferred assertion.

🤖 Generated with Claude Code

djravine and others added 2 commits May 26, 2026 11:52
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
…p-local

Fixes bradwmorris#16.

`ensureEnvValue` writes its literal `value` argument without consulting
`process.env`, so any env-var overrides set by upstream callers
(notably `install.sh --llm-port` / `--embedding-port`) were silently
discarded — `.env.local` always landed on the hardcoded `8080`/`8081`
defaults regardless of what the user passed at install time.

Wrap both `LLM_BASE_URL` and `EMBEDDING_BASE_URL` calls with
`process.env.X || '<default>'` in the `qwen-local` and `llama-cpp`
branches. The `openai` branch doesn't write base URLs (OpenAI's
endpoint is the SDK default), so it needs no change.

The `qwen-local` branch is updated for defensive symmetry — nothing
sets those env vars at install time today, but mirroring the override
pattern keeps the behaviour consistent across local-LLM profiles
(future-proofs against e.g. pointing Ollama at a non-default host).

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

bootstrap-local.mjs ignores LLM_BASE_URL / EMBEDDING_BASE_URL env vars (surfaced by PR #15 --llm-port flag)

1 participant