Skip to content

feat: add --llama-cpp-path global CLI flag mirroring LLAMA_CPP_PATH env var#583

Open
mvanhorn wants to merge 1 commit into
AlexsJones:mainfrom
mvanhorn:fix/295-llmfit-llama-cpp-path-cli-flag
Open

feat: add --llama-cpp-path global CLI flag mirroring LLAMA_CPP_PATH env var#583
mvanhorn wants to merge 1 commit into
AlexsJones:mainfrom
mvanhorn:fix/295-llmfit-llama-cpp-path-cli-flag

Conversation

@mvanhorn

Copy link
Copy Markdown
Contributor

Summary

Add a global --llama-cpp-path CLI flag that mirrors the existing LLAMA_CPP_PATH env var. Requested by @NTShop in issue #295.

Why this matters

LLAMA_CPP_PATH already exists for users who keep llama.cpp in a non-standard location. A matching CLI flag is more discoverable than an env var and is the usual ergonomic for one-shot overrides ("just this run, point at my custom build").

Changes

In llmfit-tui/src/main.rs, added --llama-cpp-path as a global flag on Cli. When present, the value is exported to LLAMA_CPP_PATH early in main(), before the binary lookup runs, so the existing find_binary chain in llmfit-core/src/providers.rs:1346 picks it up without any further plumbing.

No change to the env-var behavior; the flag stacks on top.

Testing

llmfit-tui/tests/cli_smoke.rs covers the flag-present case (env var set, lookup uses provided path) and the flag-absent case (existing env var behavior unchanged). README updated to mention the new flag alongside the env var.

Closes #295

AI was used for assistance.

@mvanhorn mvanhorn force-pushed the fix/295-llmfit-llama-cpp-path-cli-flag branch from b042330 to 61348e6 Compare May 25, 2026 16:59

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Flag itself is good. Two things to fix before this lands, inline.

Comment thread llmfit-tui/src/main.rs
let specs = detect_specs(&overrides);
if cli.json {
display::display_json_system(&specs);
if llama_cpp_path_configured {

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This makes the --json system output schema depend on whether --llama-cpp-path was passed. Two scripts running the same --json system will see different shapes based on flag presence, which is a surprising contract. The flag's job is setting an env var. If we want a providers block in the JSON, always include it, or add an explicit --providers flag. Right now this looks reverse-engineered from what the test needs to observe.

Comment thread llmfit-tui/src/main.rs
return false;
};

if path.is_dir() {

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Silently dropping the flag when the directory does not exist is a footgun. Typo the path and you get no signal, just the wrong llama.cpp picked up later. Warn to stderr, or exit non-zero. The test asserting silent ignore is baking in the wrong contract.

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.

llama.cpp is not supported

2 participants