[GH-ISSUE #14026] OLLAMA_CONTEXT_LENGTH Linux env variable error via documentation #71226

Closed
opened 2026-05-05 00:44:26 -05:00 by GiteaMirror · 1 comment
Owner

Originally created by @jasonculligan on GitHub (Feb 2, 2026).
Original GitHub issue: https://github.com/ollama/ollama/issues/14026

What is the issue?

On Linux Mint, I set the variable in my /etc/environment like so, as per the documentation:

$ cat /etc/environment
PATH="/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games:/snap/bin"
OLLAMA_CONTEXT_LENGTH=8192 ollama serve

When I then try to run a model in Ollama I get this error:

$ ollama run gpt-oss:20b
2026/02/02 10:32:08 config.go:232: WARN invalid environment variable, using default key=OLLAMA_CONTEXT_LENGTH value="8192 ollama serve" default=4096
>>> Send a message (/? for help)

Relevant log output

As above

OS

Linux

GPU

Nvidia

CPU

Intel

Ollama version

ollama version is 0.15.4

Originally created by @jasonculligan on GitHub (Feb 2, 2026). Original GitHub issue: https://github.com/ollama/ollama/issues/14026 ### What is the issue? On Linux Mint, I set the variable in my /etc/environment like so, as per the documentation: ```console $ cat /etc/environment PATH="/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games:/snap/bin" OLLAMA_CONTEXT_LENGTH=8192 ollama serve ``` When I then try to run a model in Ollama I get this error: ```console $ ollama run gpt-oss:20b 2026/02/02 10:32:08 config.go:232: WARN invalid environment variable, using default key=OLLAMA_CONTEXT_LENGTH value="8192 ollama serve" default=4096 >>> Send a message (/? for help) ``` ### Relevant log output ```shell As above ``` ### OS Linux ### GPU Nvidia ### CPU Intel ### Ollama version ollama version is 0.15.4
GiteaMirror added the bug label 2026-05-05 00:44:26 -05:00
Author
Owner

@rick-github commented on GitHub (Feb 2, 2026):

If you are running from the command line, OLLAMA_CONTEXT_LENGTH=8192 ollama serve sets the value of the variable OLLAMA_CONTEXT_LENGTH to 8192 and runs the command ollama serve. If you just want to set the value of the variable in the environment in a config file, just use OLLAMA_CONTEXT_LENGTH=8192.

<!-- gh-comment-id:3835717994 --> @rick-github commented on GitHub (Feb 2, 2026): If you are running from the command line, `OLLAMA_CONTEXT_LENGTH=8192 ollama serve` sets the value of the variable `OLLAMA_CONTEXT_LENGTH` to 8192 and runs the command `ollama serve`. If you just want to set the value of the variable in the environment in a config file, just use `OLLAMA_CONTEXT_LENGTH=8192`.
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: github-starred/ollama#71226