5
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

uvは依存関係を再ダウンロードしない

5
Last updated at Posted at 2025-12-22

TL;DR

uvはデフォルトでcacheを使用しているため、異なるディレクトリにパッケージを追加する場合も再度ダウンロードすることを防ぐ機構になっています。

Caching | uv

詳細

uvはリポジトリごとに依存関係を定義します。ただ、別のリポジトリで同様に依存関係を定義した場合、非常にすぐダウンロードが完了した経験があります。
これは、uvがデフォルトでキャッシュを使用しているためです。

実際cacheがされている場合はuv addの際にverboseモードにすることで確認できます。

uv add ruff -v
...
DEBUG Registry requirement already cached: ruff==0.14.10
...

一方で、キャッシュが存在しない場合は以下のようにダウンロードが行われます。

uv add ruff -v
...
DEBUG No cache entry for: https://files.pythonhosted.org/packages/7b/82/36be59f00a6082e38c23536df4e71cdbc6af8d7c707eade97fcad5c98235/ruff-0.14.10-py3-none-macosx_11_0_arm64.whl
...

ただ、バージョンが異なる場合は再度ダウンロードが行われます。

uv add ruff==0.13.0 -v
...
DEBUG No cache entry for: https://files.pythonhosted.org/packages/44/cf/40bc7221a949470307d9c35b4ef5810c294e6cfa3caafb57d882731a9f42/ruff-0.13.0-py3-none-macosx_11_0_arm64.whl
...

また、キャッシュのディレクトリの場所は以下のコマンドで確認できます。

uv cache dir

合わせて、cacheを削除したい場合は全体でも行えますし、特定のパッケージだけでも削除できます。

uv cache clean          # 全体のcacheを削除
uv cache clean ruff    # ruffのcacheを削除
5
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
5
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?