Error: requires at least 1 arg(s), only received 0 is what
ollama run prints when no model name reaches it. Put the model name right after
run, as in ollama run qwen2.5:0.5b, and if the name comes from a
variable, check that the variable is set before the command runs.
The fix is the missing word. In a script, one way to lose it is an empty variable: in
the test, a PowerShell variable read from an environment variable that was not set gave the
same message as typing ollama run on its own.
The error
> ollama run
Error: requires at least 1 arg(s), only received 0
And from a PowerShell script where the model name was meant to come from the environment:
PS> $model = $env:FIX12_MODEL; ollama run $model
Error: requires at least 1 arg(s), only received 0
Both returned exit code 1. After a second bare ollama run, the test server's
request log had no new line.
Why it happens
ollama run takes a model name and an optional prompt (its help line is
ollama run MODEL [PROMPT] [flags]), so the client wants one plain argument at
least. In the PowerShell case the
variable held nothing, and the client printed the same message, word for word, as for
the bare command.
Two neighbours print other words for the same mistake. ollama pull and
ollama show with no name print Error: accepts 1 arg(s), received 0,
because they take exactly one name. An empty quoted name, typed as
ollama run "" in a .cmd file, printed
Error: model is required instead.
> ollama pull
Error: accepts 1 arg(s), received 0
> ollama show
Error: accepts 1 arg(s), received 0
> type run-empty.cmd
@echo off
set OLLAMA_HOST=127.0.0.1:15190
echo on
ollama run ""
@echo exit code: %ERRORLEVEL%
> .\run-empty.cmd
...>ollama run ""
Error: model is required
exit code: 1
The fix
> ollama list
NAME ID SIZE MODIFIED
...
qwen2.5:0.5b a8b0c5157701 397 MB 3 minutes ago
...
> ollama run qwen2.5:0.5b "Say hi in three words"
Hello! How can I help you today?
ollama list shows the names the server has; copy one after run.
For the script case, the same PowerShell line worked once the variable was set first:
PS> $env:FIX12_MODEL = 'qwen2.5:0.5b'; $model = $env:FIX12_MODEL; ollama run $model 'Say hi in three words'
Hello, how are you?
The small model's answers to the prompt were not three words; the commands worked, the model did not follow the prompt.
How it was reproduced
Ollama 0.40.16 on Windows 11, with a test server of its own started by
ollama serve with OLLAMA_HOST=127.0.0.1:15190 and
OLLAMA_MODELS set to a scratch folder, into which qwen2.5:0.5b
was pulled through that server (the pull requests are in its request log).
The > lines ran in cmd.exe, sent from PowerShell as
cmd /c "<line> 2>&1", with that OLLAMA_HOST
set; the empty-name line ran from the .cmd file shown, whose echoed folder is
shortened to ...; the PS> lines ran in Windows PowerShell 5.1 started with
powershell -NoProfile, first with FIX12_MODEL not set and then
with it set on the line itself. The variable name and run-empty.cmd are the
test's own. The ollama list output is cut to the one model used
(marked with ...), and the spinner and terminal control characters of the answer are left
out.
Frequently asked
- What does ollama requires at least 1 arg(s), only received 0 mean?
- ollama run was called with no model name. Add the name after run, for example ollama run qwen2.5:0.5b.
- Why does my script get requires at least 1 arg(s) from ollama run?
- In the test, the variable that should hold the model name was empty: a PowerShell variable read from an unset environment variable passed no argument, which gave the same message as ollama run on its own.
- What is the difference between this and accepts 1 arg(s), received 0?
- ollama run takes a model name plus an optional prompt and says requires at least 1 arg(s). ollama pull and ollama show take exactly one name and say accepts 1 arg(s), received 0 for the same missing word.
More decoded errors in the Fixes category. Too many names instead of none gives 'accepts 1 arg(s), received 2'.