[GH-ISSUE #613] Getting permission denied when attempting to create a model #26032

Closed
opened 2026-04-22 01:55:02 -05:00 by GiteaMirror · 15 comments
Owner

Originally created by @DeanKamali on GitHub (Sep 27, 2023).
Original GitHub issue: https://github.com/ollama/ollama/issues/613

Originally assigned to: @mxyng on GitHub.

ollama version: v0.1.0

Steps to Reproduce:

  • Ran curl https://ollama.ai/install.sh | sh to install ollama.
  • Navigated to ollama/examples/devops-engineer/.
  • Executed ollama create devops-engineer -f ./Modelfile.

Error Encountered:
couldn't open modelfile '/root/ollama/examples/devops-engineer/Modelfile'. Error: failed to open file: open /root/ollama/examples/devops-engineer/Modelfile: permission denied.

image
After trying to set the Model file with 755 in my WSL environment, I still couldn't get it to work. I'm wondering if there is a bug with the recent Linux release.

Originally created by @DeanKamali on GitHub (Sep 27, 2023). Original GitHub issue: https://github.com/ollama/ollama/issues/613 Originally assigned to: @mxyng on GitHub. ollama version: v0.1.0 **Steps to Reproduce:** - Ran` curl https://ollama.ai/install.sh | sh` to install ollama. - Navigated to ollama/examples/devops-engineer/. - Executed `ollama create devops-engineer -f ./Modelfile`. Error Encountered: `couldn't open modelfile '/root/ollama/examples/devops-engineer/Modelfile'. Error: failed to open file: open /root/ollama/examples/devops-engineer/Modelfile: permission denied.` ![image](https://github.com/jmorganca/ollama/assets/1252959/4da3d481-87f3-4472-aba8-97ceb71df8f0) After trying to set the Model file with 755 in my WSL environment, I still couldn't get it to work. I'm wondering if there is a bug with the recent Linux release.
GiteaMirror added the bug label 2026-04-22 01:55:02 -05:00
Author
Owner

@syhw commented on GitHub (Sep 27, 2023):

You need to be in a folder accessible/browsable by the ollama user. A solution is to make your home traversable (a+x).

<!-- gh-comment-id:1736851295 --> @syhw commented on GitHub (Sep 27, 2023): You need to be in a folder accessible/browsable by the `ollama` user. A solution is to make your home traversable (`a+x`).
Author
Owner

@AlexandrePoisson commented on GitHub (Oct 4, 2023):

I am also using WSL2, ubuntu, and I get the same message, even afer chmod a+x /home/, chmod a+x /home/modelfiles and chmod 777 the modelfile,

couldn't open modelfile '/home/alexandre/modelfiles/Modelfile' Error: failed to open file: open /home/alexandre/modelfiles/Modelfile: permission denied

Not sure the version I am using, maybe a ollama version command would be usefull. I've installed it the 01 oct. 2023 using
curl https://ollama.ai/install.sh | sh

<!-- gh-comment-id:1746912591 --> @AlexandrePoisson commented on GitHub (Oct 4, 2023): I am also using WSL2, ubuntu, and I get the same message, even afer chmod a+x /home/, chmod a+x /home/modelfiles and chmod 777 the modelfile, `couldn't open modelfile '/home/alexandre/modelfiles/Modelfile' Error: failed to open file: open /home/alexandre/modelfiles/Modelfile: permission denied` Not sure the version I am using, maybe a ollama version command would be usefull. I've installed it the 01 oct. 2023 using `curl https://ollama.ai/install.sh | sh`
Author
Owner

@nalyk commented on GitHub (Oct 7, 2023):

A solution is to make your home traversable (a+x).

You need to be in a folder accessible/browsable by the ollama user. A solution is to make your home traversable (a+x).

No working

NAME="Linux Mint"
VERSION="21.1 (Vera)"
ID=linuxmint
ID_LIKE="ubuntu debian"
PRETTY_NAME="Linux Mint 21.1"
VERSION_ID="21.1"
HOME_URL="https://www.linuxmint.com/"
SUPPORT_URL="https://forums.linuxmint.com/"
BUG_REPORT_URL="http://linuxmint-troubleshooting-guide.readthedocs.io/en/latest/"
PRIVACY_POLICY_URL="https://www.linuxmint.com/"
VERSION_CODENAME=vera
UBUNTU_CODENAME=jammy

<!-- gh-comment-id:1751773562 --> @nalyk commented on GitHub (Oct 7, 2023): A solution is to make your home traversable (a+x). > You need to be in a folder accessible/browsable by the `ollama` user. A solution is to make your home traversable (`a+x`). No working NAME="Linux Mint" VERSION="21.1 (Vera)" ID=linuxmint ID_LIKE="ubuntu debian" PRETTY_NAME="Linux Mint 21.1" VERSION_ID="21.1" HOME_URL="https://www.linuxmint.com/" SUPPORT_URL="https://forums.linuxmint.com/" BUG_REPORT_URL="http://linuxmint-troubleshooting-guide.readthedocs.io/en/latest/" PRIVACY_POLICY_URL="https://www.linuxmint.com/" VERSION_CODENAME=vera UBUNTU_CODENAME=jammy
Author
Owner

@shayakogan commented on GitHub (Oct 9, 2023):

still no solution?

<!-- gh-comment-id:1753730999 --> @shayakogan commented on GitHub (Oct 9, 2023): still no solution?
Author
Owner

@jmorganca commented on GitHub (Oct 10, 2023):

Hey all, sorry you're hitting this issue. Ollama on linux uses a user ollama to run in the background, but unfortunately this user doesn't have access to all files (including Modelfiles in your user directory).

Working on a fix, and in the meantime you can add your current user to the ollama group:

usermod -aG ollama $USER

If you're root, the easiest way for the time being is to allow other users to access a specific directory that contains the Modelfile

chmod -R o+rx <dir containing Modelfile>
<!-- gh-comment-id:1756293841 --> @jmorganca commented on GitHub (Oct 10, 2023): Hey all, sorry you're hitting this issue. Ollama on linux uses a user `ollama` to run in the background, but unfortunately this user doesn't have access to all files (including `Modelfile`s in your user directory). Working on a fix, and in the meantime you can add your current user to the `ollama` group: ``` usermod -aG ollama $USER ``` If you're `root`, the easiest way for the time being is to allow other users to access a specific directory that contains the `Modelfile` ``` chmod -R o+rx <dir containing Modelfile> ```
Author
Owner

@samskarion commented on GitHub (Oct 13, 2023):

Hey all, sorry you're hitting this issue. Ollama on linux uses a user ollama to run in the background, but unfortunately this user doesn't have access to all files (including Modelfiles in your user directory).

Working on a fix, and in the meantime you can add your current user to the ollama group:

usermod -aG ollama $USER

If you're root, the easiest way for the time being is to allow other users to access a specific directory that contains the Modelfile

chmod -R o+rx <dir containing Modelfile>

This didnt work for me still somehow BUT I ended up just copying the whole folder to /tmp and building from there. Worked like a charm

<!-- gh-comment-id:1762146736 --> @samskarion commented on GitHub (Oct 13, 2023): > Hey all, sorry you're hitting this issue. Ollama on linux uses a user `ollama` to run in the background, but unfortunately this user doesn't have access to all files (including `Modelfile`s in your user directory). > > Working on a fix, and in the meantime you can add your current user to the `ollama` group: > > ``` > usermod -aG ollama $USER > ``` > > If you're `root`, the easiest way for the time being is to allow other users to access a specific directory that contains the `Modelfile` > > ``` > chmod -R o+rx <dir containing Modelfile> > ``` This didnt work for me still somehow BUT I ended up just copying the whole folder to /tmp and building from there. Worked like a charm
Author
Owner

@usUpal commented on GitHub (Oct 16, 2023):

Hey all, sorry you're hitting this issue. Ollama on linux uses a user ollama to run in the background, but unfortunately this user doesn't have access to all files (including Modelfiles in your user directory).
Working on a fix, and in the meantime you can add your current user to the ollama group:

usermod -aG ollama $USER

If you're root, the easiest way for the time being is to allow other users to access a specific directory that contains the Modelfile

chmod -R o+rx <dir containing Modelfile>

This didnt work for me still somehow BUT I ended up just copying the whole folder to /tmp and building from there. Worked like a charm

/tmp dir worked for me as well

<!-- gh-comment-id:1763570233 --> @usUpal commented on GitHub (Oct 16, 2023): > > Hey all, sorry you're hitting this issue. Ollama on linux uses a user `ollama` to run in the background, but unfortunately this user doesn't have access to all files (including `Modelfile`s in your user directory). > > Working on a fix, and in the meantime you can add your current user to the `ollama` group: > > ``` > > usermod -aG ollama $USER > > ``` > > > > > > If you're `root`, the easiest way for the time being is to allow other users to access a specific directory that contains the `Modelfile` > > ``` > > chmod -R o+rx <dir containing Modelfile> > > ``` > > This didnt work for me still somehow BUT I ended up just copying the whole folder to /tmp and building from there. Worked like a charm /tmp dir worked for me as well
Author
Owner

@espadrine commented on GitHub (Nov 7, 2023):

Is this issue truly fixed? I can see that my user is indeed added to the ollama group with grep '^ollama:' /etc/group, but the binary is still run as the ollama user, and thus cannot access files in the home directory, right? I tried running ollama create openchat -f ./openchat/Modelfile, with a freshly compiled binary put on /usr/local/bin and with sudo systemctl restart ollama, but the error remains.

<!-- gh-comment-id:1797112835 --> @espadrine commented on GitHub (Nov 7, 2023): Is this issue truly fixed? I can see that my user is indeed added to the ollama group with `grep '^ollama:' /etc/group`, but the binary is still run as the ollama user, and thus cannot access files in the home directory, right? I tried running `ollama create openchat -f ./openchat/Modelfile`, with a freshly compiled binary put on /usr/local/bin and with `sudo systemctl restart ollama`, but the error remains.
Author
Owner

@eramax commented on GitHub (Nov 7, 2023):

I have the same issue

<!-- gh-comment-id:1800350260 --> @eramax commented on GitHub (Nov 7, 2023): I have the same issue
Author
Owner

@romanoff commented on GitHub (Nov 8, 2023):

Same for me

<!-- gh-comment-id:1800840423 --> @romanoff commented on GitHub (Nov 8, 2023): Same for me
Author
Owner

@jidun67 commented on GitHub (Nov 11, 2023):

I just thought it was me but, now I see it's not. I am not gonna try the temp dir fix I tried the others and had no luck :( I will keep an eye out for the fix I doubt I'd be much help in that area.

<!-- gh-comment-id:1806945619 --> @jidun67 commented on GitHub (Nov 11, 2023): I just thought it was me but, now I see it's not. I am not gonna try the temp dir fix I tried the others and had no luck :( I will keep an eye out for the fix I doubt I'd be much help in that area.
Author
Owner

@marianoarga commented on GitHub (Jan 8, 2024):

Hey all, sorry you're hitting this issue. Ollama on linux uses a user ollama to run in the background, but unfortunately this user doesn't have access to all files (including Modelfiles in your user directory).
Working on a fix, and in the meantime you can add your current user to the ollama group:

usermod -aG ollama $USER

If you're root, the easiest way for the time being is to allow other users to access a specific directory that contains the Modelfile

chmod -R o+rx <dir containing Modelfile>

This didnt work for me still somehow BUT I ended up just copying the whole folder to /tmp and building from there. Worked like a charm

@samskarion wich folder you move and where to?, thanks

<!-- gh-comment-id:1881214259 --> @marianoarga commented on GitHub (Jan 8, 2024): > > Hey all, sorry you're hitting this issue. Ollama on linux uses a user `ollama` to run in the background, but unfortunately this user doesn't have access to all files (including `Modelfile`s in your user directory). > > Working on a fix, and in the meantime you can add your current user to the `ollama` group: > > ``` > > usermod -aG ollama $USER > > ``` > > > > > > > > > > > > > > > > > > > > > > > > If you're `root`, the easiest way for the time being is to allow other users to access a specific directory that contains the `Modelfile` > > ``` > > chmod -R o+rx <dir containing Modelfile> > > ``` > > This didnt work for me still somehow BUT I ended up just copying the whole folder to /tmp and building from there. Worked like a charm @samskarion wich folder you move and where to?, thanks
Author
Owner

@arsenij-ust commented on GitHub (Jan 9, 2024):

Hey all, for me worked to change the group ownership of the directory containing the models to ollama with sudo chown -R $USER:ollama <ollama models dir>. This solved the issue. Hope it helps.

<!-- gh-comment-id:1883475429 --> @arsenij-ust commented on GitHub (Jan 9, 2024): Hey all, for me worked to change the group ownership of the directory containing the models to ollama with `sudo chown -R $USER:ollama <ollama models dir>`. This solved the issue. Hope it helps.
Author
Owner

@guoshuqi1212 commented on GitHub (Dec 2, 2024):

That is due to not sudo user. Use a Different Temporary Directory is fine.

mkdir -p ~/ollama_tmp
export OLLAMA_TMPDIR=~/ollama_tmp
ollama serve

just try

<!-- gh-comment-id:2510564767 --> @guoshuqi1212 commented on GitHub (Dec 2, 2024): That is due to not sudo user. Use a Different Temporary Directory is fine. ``` mkdir -p ~/ollama_tmp export OLLAMA_TMPDIR=~/ollama_tmp ollama serve ``` just try
Author
Owner

@highfillgoods commented on GitHub (Feb 8, 2025):

I didn't need to use temp directory. Just make sure ollama service is completely stopped and any other app that might be using it like msty or open-webui is stopped also. Change permissions, add user to ollama group, whatever you need.

sudo systemctl stop ollama.service 
systemctl status ollama
#usermod -aG ollama $USER
#chmod -R o+rx <dir containing Modelfile>
sudo systemctl start ollama.service 
ollama serve

Open new terminal and do an ollama pull should work.

here is what my user permissions look like for models.

/usr/share/ollama/.ollama$ ls -l
-rw------- 1 ollama ollama  387 Feb  7 17:56 id_ed25519
-rw-r--r-- 1 ollama ollama   81 Feb  7 17:56 id_ed25519.pub
drwxr-xr-x 4 user   ollama 4096 Feb  7 17:58 models
<!-- gh-comment-id:2644451081 --> @highfillgoods commented on GitHub (Feb 8, 2025): I didn't need to use temp directory. Just make sure ollama service is completely stopped and any other app that might be using it like msty or open-webui is stopped also. Change permissions, add user to ollama group, whatever you need. ``` sudo systemctl stop ollama.service systemctl status ollama #usermod -aG ollama $USER #chmod -R o+rx <dir containing Modelfile> sudo systemctl start ollama.service ollama serve ``` Open new terminal and do an ollama pull should work. here is what my user permissions look like for models. ``` /usr/share/ollama/.ollama$ ls -l -rw------- 1 ollama ollama 387 Feb 7 17:56 id_ed25519 -rw-r--r-- 1 ollama ollama 81 Feb 7 17:56 id_ed25519.pub drwxr-xr-x 4 user ollama 4096 Feb 7 17:58 models ```
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: github-starred/ollama#26032