[GH-ISSUE #8756] panic: $HOME is not defined #5682

Closed
opened 2026-04-12 16:58:36 -05:00 by GiteaMirror · 5 comments
Owner

Originally created by @ozbillwang on GitHub (Feb 1, 2025).
Original GitHub issue: https://github.com/ollama/ollama/issues/8756

What is the issue?

when manually run ollama pull deepseek-r1:8b, it is fine.

But when I put it in init script user-data.sh in ec2 instance, I got error

pull-model-1 | goroutine 1 [running]:
pull-model-1 | github.com/ollama/ollama/envconfig.Models()
pull-model-1 | github.com/ollama/ollama/envconfig/config.go:93 +0xa9
pull-model-1 | github.com/ollama/ollama/envconfig.AsMap()
pull-model-1 | github.com/ollama/ollama/envconfig/config.go:253 +0x699
pull-model-1 | github.com/ollama/ollama/cmd.NewCLI()
pull-model-1 | github.com/ollama/ollama/cmd/cmd.go:1329 +0xb68
pull-model-1 | main.main()
pull-model-1 | github.com/ollama/ollama/main.go:12 +0x13
pull-model-1 | panic: $HOME is not defined

before run the pull command, I checked the ollama service is running with systemctl status ollama

Run on ubuntu 24.04, t2.large and g4dn.xlarge, got same error.

OS

Linux

GPU

Nvidia

CPU

Intel

Ollama version

latest, 0.5.7

Originally created by @ozbillwang on GitHub (Feb 1, 2025). Original GitHub issue: https://github.com/ollama/ollama/issues/8756 ### What is the issue? when manually run `ollama pull deepseek-r1:8b`, it is fine. But when I put it in init script `user-data.sh` in ec2 instance, I got error ``` pull-model-1 | goroutine 1 [running]: pull-model-1 | github.com/ollama/ollama/envconfig.Models() pull-model-1 | github.com/ollama/ollama/envconfig/config.go:93 +0xa9 pull-model-1 | github.com/ollama/ollama/envconfig.AsMap() pull-model-1 | github.com/ollama/ollama/envconfig/config.go:253 +0x699 pull-model-1 | github.com/ollama/ollama/cmd.NewCLI() pull-model-1 | github.com/ollama/ollama/cmd/cmd.go:1329 +0xb68 pull-model-1 | main.main() pull-model-1 | github.com/ollama/ollama/main.go:12 +0x13 pull-model-1 | panic: $HOME is not defined ``` before run the pull command, I checked the ollama service is running with `systemctl status ollama` Run on `ubuntu 24.04`, `t2.large` and `g4dn.xlarge`, got same error. ### OS Linux ### GPU Nvidia ### CPU Intel ### Ollama version latest, 0.5.7
GiteaMirror added the bug label 2026-04-12 16:58:36 -05:00
Author
Owner

@ozbillwang commented on GitHub (Feb 1, 2025):

same issue was discussed in https://github.com/docker/genai-stack/issues/176

<!-- gh-comment-id:2628887471 --> @ozbillwang commented on GitHub (Feb 1, 2025): same issue was discussed in https://github.com/docker/genai-stack/issues/176
Author
Owner

@rick-github commented on GitHub (Feb 1, 2025):

Set HOME in the script.

export HOME=/the/home/dir/of/ollama
<!-- gh-comment-id:2628917671 --> @rick-github commented on GitHub (Feb 1, 2025): Set HOME in the script. ``` export HOME=/the/home/dir/of/ollama ```
Author
Owner

@ozbillwang commented on GitHub (Feb 2, 2025):

Still same issue

Image

i can only define the environment variable in its service file /etc/systemd/system/ollama.service

add this line: Environment="HOME=/root"

root@ip-172-31-32-45:/var/log# cat /etc/systemd/system/ollama.service
[Unit]
Description=Ollama Service
After=network-online.target

[Service]
Environment="HOME=/root"
Environment="OLLAMA_HOST=0.0.0.0"
ExecStart=/usr/local/bin/ollama serve
User=ollama
Group=ollama
Restart=always
RestartSec=3
Environment="PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/snap/bin"

[Install]
WantedBy=default.target
root@ip-172-31-32-45:/var/log#
<!-- gh-comment-id:2629501986 --> @ozbillwang commented on GitHub (Feb 2, 2025): Still same issue ![Image](https://github.com/user-attachments/assets/50922cd0-6023-43f7-a107-dfd9d64bee72) i can only define the environment variable in its service file `/etc/systemd/system/ollama.service` add this line: `Environment="HOME=/root"` ``` root@ip-172-31-32-45:/var/log# cat /etc/systemd/system/ollama.service [Unit] Description=Ollama Service After=network-online.target [Service] Environment="HOME=/root" Environment="OLLAMA_HOST=0.0.0.0" ExecStart=/usr/local/bin/ollama serve User=ollama Group=ollama Restart=always RestartSec=3 Environment="PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/snap/bin" [Install] WantedBy=default.target root@ip-172-31-32-45:/var/log# ```
Author
Owner

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

You said you were running ollama in user-data.sh. That's where HOME needs to be set.

<!-- gh-comment-id:2629556779 --> @rick-github commented on GitHub (Feb 2, 2025): You said you were running ollama in `user-data.sh`. That's where HOME needs to be set.
Author
Owner

@ozbillwang commented on GitHub (Feb 2, 2025):

Thanks, the issue is fixed.

<!-- gh-comment-id:2629561335 --> @ozbillwang commented on GitHub (Feb 2, 2025): Thanks, the issue is fixed.
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: github-starred/ollama#5682