[GH-ISSUE #2940] OLLAMA_MODELS env variable in bashrc doesnt work #27564

Closed
opened 2026-04-22 05:00:02 -05:00 by GiteaMirror · 6 comments
Owner

Originally created by @harsham05 on GitHub (Mar 5, 2024).
Original GitHub issue: https://github.com/ollama/ollama/issues/2940

Originally assigned to: @bmizerany on GitHub.

Ive added the following to my .bashrc but Ollama doesnt seem to storing them there.

export OLLAMA_MODELS=/path/to/models/

Originally created by @harsham05 on GitHub (Mar 5, 2024). Original GitHub issue: https://github.com/ollama/ollama/issues/2940 Originally assigned to: @bmizerany on GitHub. Ive added the following to my .bashrc but Ollama doesnt seem to storing them there. `export OLLAMA_MODELS=/path/to/models/`
Author
Owner

@easp commented on GitHub (Mar 5, 2024):

What platform are you using? That's only going to work if you launch ollama serve from a bash shell. If you are using Mac, or Windows, or the service that's installed on linux you have to set the environment variables other ways:

https://github.com/ollama/ollama/blob/main/docs/faq.md#how-do-i-configure-ollama-server

<!-- gh-comment-id:1979548828 --> @easp commented on GitHub (Mar 5, 2024): What platform are you using? That's only going to work if you launch `ollama serve` from a bash shell. If you are using Mac, or Windows, or the service that's installed on linux you have to set the environment variables other ways: https://github.com/ollama/ollama/blob/main/docs/faq.md#how-do-i-configure-ollama-server
Author
Owner

@harsham05 commented on GitHub (Mar 5, 2024):

Im using Linux.

<!-- gh-comment-id:1979811609 --> @harsham05 commented on GitHub (Mar 5, 2024): Im using Linux.
Author
Owner

@bmizerany commented on GitHub (Mar 6, 2024):

@harsham05 Will you please provide the output of echo $OLLAMA_MODELS from a fresh bash session?

<!-- gh-comment-id:1981893812 --> @bmizerany commented on GitHub (Mar 6, 2024): @harsham05 Will you please provide the output of `echo $OLLAMA_MODELS` from a fresh bash session?
Author
Owner

@mxyng commented on GitHub (Mar 6, 2024):

As @easp already mentioned, OLLAMA_MODELS must be set in the same context as ollama serve. Setting it in .bashrc is probably not what you want unless you're invoking ollama serve directly.

Since you're using Linux, is it possible there's an systemd ollama.service running? If so, you'll need to set OLLAMA_MODELS in the systemd service. This section of the FAQ has the details.

<!-- gh-comment-id:1981911703 --> @mxyng commented on GitHub (Mar 6, 2024): As @easp already mentioned, `OLLAMA_MODELS` must be set in the same context as `ollama serve`. Setting it in `.bashrc` is _probably_ not what you want _unless_ you're invoking `ollama serve` directly. Since you're using Linux, is it possible there's an systemd ollama.service running? If so, you'll need to set `OLLAMA_MODELS` in the systemd service. [This](https://github.com/ollama/ollama/blob/main/docs/faq.md#setting-environment-variables-on-linux) section of the FAQ has the details.
Author
Owner

@jmorganca commented on GitHub (Mar 12, 2024):

Will close this for now, see @mxyng's answer for best practices currently

<!-- gh-comment-id:1989735681 --> @jmorganca commented on GitHub (Mar 12, 2024): Will close this for now, see @mxyng's answer for best practices currently
Author
Owner

@Nilabb commented on GitHub (Jul 5, 2024):

Ive added the following to my .bashrc but Ollama doesnt seem to storing them there.

export OLLAMA_MODELS=/path/to/models/

If you look at the ollama daemon configuration file you might notice a few things.

ExecStart=/usr/bin/ollama serve
...
User=ollama
Group=ollama

This means when you start ollama you are executing ollama serve as the user ollama. Just as if you were to use sudo -u ollama ollama serve. So, if it's in your .bashrc and not ollama's, it probably can't recognise it.
Also see https://github.com/ollama/ollama/blob/main/docs/faq.md#how-do-i-configure-ollama-server
and https://github.com/ollama/ollama/blob/main/docs/faq.md#where-are-models-stored
note that this also means the ollama user needs permissions to edit the folder

<!-- gh-comment-id:2210732910 --> @Nilabb commented on GitHub (Jul 5, 2024): > Ive added the following to my .bashrc but Ollama doesnt seem to storing them there. > > `export OLLAMA_MODELS=/path/to/models/` If you look at the ollama daemon configuration file you might notice a few things. ``` ExecStart=/usr/bin/ollama serve ... User=ollama Group=ollama ``` This means when you start ollama you are executing `ollama serve` as the user ollama. Just as if you were to use `sudo -u ollama ollama serve`. So, if it's in your .bashrc and not ollama's, it probably can't recognise it. Also see https://github.com/ollama/ollama/blob/main/docs/faq.md#how-do-i-configure-ollama-server and https://github.com/ollama/ollama/blob/main/docs/faq.md#where-are-models-stored note that this also means the ollama user needs permissions to edit the folder
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: github-starred/ollama#27564