bash: ollama: command not found and zsh: command not found: ollama
mean the shell found no ollama program in any folder on its PATH. Either Ollama
is not installed on that machine, or it is installed in a folder the PATH does not list.
command -v ollama tells you whether the shell sees it; the fix is to install it, or
to call it by full path or add its folder to PATH.
Both causes were reproduced in Linux containers below. If command -v ollama
prints nothing and the binary is nowhere on disk, install Ollama. If the binary exists, put
its folder on PATH.
The error
Bash in a fresh ubuntu:24.04 container, Ollama not installed:
$ bash -ic "ollama --version"
...
bash: ollama: command not found
exit=127
$ command -v ollama
exit=1
zsh 5.9 in the same image, reading the command at its interactive prompt:
$ echo "ollama --version" | zsh -i -f
...
783f3d96427b# zsh: command not found: ollama
...
783f3d96427b# exit=127
Run as zsh -ic "ollama --version", the same zsh printed
zsh:1: command not found: ollama, with the line number in front. The zsh
wording is shown here from Linux; nothing in this post was run on a Mac.
Why it happens
The exit status 127 and the empty command -v say the same thing: no folder on
PATH holds a file called ollama. In the first case there was nothing to find.
In the second, the ollama/ollama image was started with a PATH that leaves out
/usr/bin, where that image keeps the binary. The file was on disk and ran by
its full path, yet Bash gave the same message:
PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/sbin
$ /bin/bash -ic "ollama --version"
...
bash: ollama: command not found
exit=127
$ command -v ollama
exit=1
$ /bin/ls -l /usr/bin/ollama
-rwxr-xr-x 1 root root 30168944 Oct 21 21:11 /usr/bin/ollama
$ /usr/bin/ollama --version
Warning: could not connect to a running Ollama instance
Warning: client version is 0.40.8
The two warnings there are printed by Ollama itself (no server ran in that container); they show that the program started.
The fix
If the binary exists, add its folder to PATH and check again:
$ export PATH="$PATH:/usr/bin"
$ command -v ollama
/usr/bin/ollama
$ ollama --version
Warning: could not connect to a running Ollama instance
Warning: client version is 0.40.8
Use the folder that holds your own ollama binary, as command -v
in a working shell or the full path shows; /usr/bin is this image's folder.
export lasts for that shell. To keep it, put the same line in the startup file
of your shell (~/.bashrc for Bash, ~/.zshrc for zsh); that step was
not part of this test. If no ollama file exists anywhere, the fix is to install
it: the steps, including the zstd package a bare Ubuntu needs, are in
Install Ollama on Linux and WSL.
How it was reproduced
Docker Engine 29.9.3 on Windows 11. Not installed: docker run --name fix9-olc-ubuntu
on ubuntu:24.04 ran bash -ic, then installed zsh 5.9 with apt-get
and ran the command in zsh; the interactive zsh capture came from a third container,
fix9-olc-zsh, on the same image. Not on PATH: docker run --name fix9-olc-path -e
PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/sbin --entrypoint /bin/bash ollama/ollama
with a script mounted read-only; the image's client reports version 0.40.8. All three containers
are the test's own and were removed afterwards.
Frequently asked
- Why does bash say ollama: command not found?
- No folder on the shell's PATH contains an ollama program. Run command -v ollama; if it prints nothing, either install Ollama or add the folder that holds the binary to PATH.
- How do I check where ollama is installed on Linux?
- In a shell where it runs, command -v ollama prints the path. In the ollama/ollama image used here it was /usr/bin/ollama.
- What does zsh: command not found: ollama mean?
- The same as the Bash message: zsh found no ollama on its PATH. Install Ollama, or add the folder that holds the binary to PATH, and check again with command -v ollama.
More decoded errors in the Fixes category. Seeing this inside WSL while Ollama runs as the Windows app is a separate case: ollama: command not found in WSL with the Windows app. On Windows itself the message reads differently, see 'ollama' is not recognized.