Fixed: "route: bad keyword" When uv run route Runs the System Command
A Python project's command, named route, worked inside the project but answered route: bad keyword: I lost my card when I ran it from another folder. That message came from the operating system's network tool, also called route, which uv run ran instead. Giving the project's command a name no system tool uses fixed it.
What I Was Doing
A Python project, built with uv 0.13.10, has one command declared in its pyproject.toml:
[project.scripts]
route = "support_intent_router.cli:main"
route takes a customer's message and prints the topic it's about. Inside the project folder it worked:
uv run route --help
usage: route [-h] message
Route a customer support message to its intent.
positional arguments:
message the customer's message, in quotes
options:
-h, --help show this help message and exit
![The terminal after uv run route --help inside the project: the project's own usage, route [-h] message, and its description, Route a customer support message to its intent.](https://strdewiridedevblogsprod.blob.core.windows.net/images/blog/programming/python/fixes/2026/uv-route-name-02-inside.webp)
Then I ran the same command from a different folder.
What I Expected
Either the project's command, or an error saying there's no such command here.
What I Got
uv run route "I lost my card"
route: bad keyword: I lost my card
usage: route [-dnqtv] command [[modifiers] args]
![The terminal after uv run route "I lost my card" outside the project: route: bad keyword: I lost my card, then usage: route [-dnqtv] command [[modifiers] args], the usage of a different program.](https://strdewiridedevblogsprod.blob.core.windows.net/images/blog/programming/python/fixes/2026/uv-route-name-01-system.webp)
That usage line, route [-dnqtv] command [[modifiers] args], isn't my program's. My route only takes a message.
What I Checked
I asked the shell which route it finds:
which route
/sbin/route
/sbin/route is macOS's tool for viewing and changing network routes. Linux has a route command too, and so does Windows.
The uv reference explains what uv run does in each place: "When used in a project, the project environment will be created and updated before invoking the command. When used outside a project, if a virtual environment can be found in the current directory or a parent directory, the command will be run in that environment. Otherwise, the command will be run in the environment of the discovered interpreter."
Why It Happens
Inside the project, uv run puts the project's environment first, so its route wins. Outside it, there's no project environment, so the name is looked up like any other command, and the system's route is found. The same happens to anyone who installs the project and types route directly. A command name shares one space with every program already on the computer.
The Fix
Give the command a name no system tool uses. In pyproject.toml:
[project.scripts]
route-message = "support_intent_router.cli:main"
Inside the project, the next uv run rebuilds the project and installs the new name:
uv run route-message --help
Built support-intent-router @ file:///Users/you/source/dewiride-support-intent-router
Uninstalled 1 package in 1ms
Installed 1 package in 2ms
usage: route-message [-h] message
Route a customer support message to its intent.
positional arguments:
message the customer's message, in quotes
options:
-h, --help show this help message and exit
![The terminal after uv run route-message --help inside the project: uv rebuilt the project, then usage: route-message [-h] message with its description.](https://strdewiridedevblogsprod.blob.core.windows.net/images/blog/programming/python/fixes/2026/uv-route-name-03-renamed.webp)
After the Fix
Outside the project, the new name no longer reaches a stranger's program:
uv run route-message "I lost my card"
error: Failed to spawn: route-message
cause: No such file or directory (os error 2)

That's the right answer: there's no route-message here, and uv says so instead of running something else. The commands work the same in PowerShell, apart from which, whose PowerShell counterpart is Get-Command route.
Common Mistakes
| Mistake | What happens | Do this instead |
|---|---|---|
Naming a command after a common tool, such as route, test, time or open | Outside the project, or for anyone who installs it, the other program runs | Check first with which <name>, or Get-Command <name> in PowerShell; pick a name that finds nothing |
| Renaming the command but not the instructions | People keep typing the old name | Update the README and any scripts in the same change |
FAQ
Is it safe inside the project?
Yes: uv run puts the project's environment first there. The trouble starts anywhere else, which is why a unique name is the real fix.
Does Python warn about the clash?
No. Nothing checks your command names against the system's.
Conclusion
route: bad keyword: I lost my card came from macOS's /sbin/route, which uv run ran because there was no project in that folder. Renaming the project's command to route-message made it unmistakable, and running it in the wrong place now gives a clear Failed to spawn instead.
Additional Resources
- uv run — how uv chooses the environment a command runs in.
- Command-line interfaces — declaring commands in
[project.scripts].
