uv tool
A “tool” is a Python script or executable that’s stored in its own virtual environments (docs)
The next tips will use the linter ruff
as an example tool.
”On the fly” tool
uv tool run ruff
This will create a new virtual environment, install ruff
and its dependencies and execute the command ruff
. The first execution will require downloading ruff
and its dependencies. Even though a virtual env needs to be created on each execution, subsequent ones are much faster because they leverage the uv
cache.
The command uvx
is an alias to uv tool run
. Therefore, this command is identical to the previous one.
uvx ruff
Installed tool
uv tool install ruff
This will installed ruff
on the PATH
. ruff
can be accessed outside of uv
and used in scripting for example.
ruff
If using uv tool run ruff
or uvx ruff
, will used the installed tool. Use --isolated
to force an isolated instance (docs)