1
0
mirror of https://github.com/jbranchaud/til synced 2026-07-08 18:10:33 +00:00

Add Globally Install CLI Tool With UV as a Python TIL

This commit is contained in:
jbranchaud
2026-07-08 11:03:23 -05:00
parent d39156d424
commit 02ea96f15f
2 changed files with 53 additions and 1 deletions
+2 -1
View File
@@ -10,7 +10,7 @@ working across different projects via [VisualMode](https://www.visualmode.dev/).
For a steady stream of TILs, [sign up for my newsletter](https://visualmode.kit.com/newsletter).
_1813 TILs and counting..._
_1814 TILs and counting..._
See some of the other learning resources I work on:
@@ -1081,6 +1081,7 @@ If you've learned something here, support my efforts writing daily TILs by
- [Enable Pyright Type Checking In Cursor](python/enable-pyright-type-checking-in-cursor.md)
- [Get Absolute Seconds From `timedelta` Object](python/get-absolute-seconds-from-timedelta-object.md)
- [Get Quotient And Remainder In One Operation](python/get-quotient-and-remainder-in-one-operation.md)
- [Globally Install CLI Tool With UV](python/globally-install-cli-tool-with-uv.md)
- [Install With PIP For Specific Interpreter](python/install-with-pip-for-specific-interpreter.md)
- [Iterate First N Items From Enumerable](python/iterate-first-n-items-from-enumerable.md)
- [Iterate Over A Dictionary](python/iterate-over-a-dictionary.md)
@@ -0,0 +1,51 @@
# Globally Install CLI Tool With UV
When I add a tool like [`ruff`](https://github.com/astral-sh/ruff) to my project
with [`uv`](https://docs.astral.sh/uv/):
```bash
uv add --dev ruff
```
Then I can run that tool within that project using `uv`:
```bash
uv run ruff format
```
However if I want to be able to run that tool via its binary directly,
especially outside the context of that project, then I need to instead install
it globally.
This can be done with `uv` using the `tool install` subcommand:
```bash
uv tool install ruff
Resolved 1 package in 192ms
Installed 1 package in 4ms
+ ruff==0.15.20
Installed 1 executable: ruff
```
Now I can run `ruff` directly from anywhere:
```bash
ruff config line-length
The line length to use when enforcing long-lines violations (like `E501`)
and at which `isort` and the formatter prefers to wrap lines.
...
```
The `ruff` binary gets symlinked into my `.local/bin/` directory which is coming
from the `uv` tool directory.
```bash
which ruff
/Users/lastword/.local/bin/ruff
readlink -n /Users/lastword/.local/bin/ruff
/Users/lastword/.local/share/uv/tools/ruff/bin/ruff
```
See `uv tool install --help` for more details.