Skip to content

Re-running installer to add a second model does not update OLLAMA_MODEL_PREF in .env #62

@Raze3478

Description

@Raze3478

When the installer is run a second time to add an additional model, the .env
update path checks only whether LLM_PROVIDER=ollama is already set:

if ($existing -match 'LLM_PROVIDER=ollama') {
    Write-Host " AnythingLLM already configured for Ollama." -ForegroundColor Green
}

If the condition is true, the file is left untouched. This means
OLLAMA_MODEL_PREF retains the value from the first install run and is never
updated to reflect the newly added model.

A user who installs model 5 (Llama 3.2 3B) first, then re-runs the installer
to add model 1 (NemoMix 12B), will find AnythingLLM still pointing to
llama3-local with no indication that the configuration was not updated.

Steps to reproduce

  1. Run install.bat, select model 5 (Llama 3.2 3B)
  2. Confirm anythingllm_data/storage/.env contains OLLAMA_MODEL_PREF=llama3-local
  3. Re-run install.bat, select model 1 (NemoMix 12B)
  4. Check .envOLLAMA_MODEL_PREF still reads llama3-local

Expected behaviour
The installer should update OLLAMA_MODEL_PREF to the first model in the
current selection, or prompt the user to choose which installed model
AnythingLLM should default to.

Proposed fix
When .env already exists with LLM_PROVIDER=ollama, use a targeted
find-and-replace on the OLLAMA_MODEL_PREF line rather than skipping the
file entirely:

(Get-Content $envFilePath) -replace 'OLLAMA_MODEL_PREF=.*', "OLLAMA_MODEL_PREF=$firstModelLocal" |
    Set-Content $envFilePath -Encoding UTF8

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions