You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I do a lot of work in offline environments with an alternate package index. That index goes down sometimes (much more often than the public pypi repo would).
A lot of routine uv/uvx tasks will check against network locations before running unless the --offline flag is passed. When the index goes offline I can continue working with the --offline flag and uv/uvx will use its local cache. This is great!
The issue is when I start having scripts or other tooling that invoke uvx. When the index is up, I don't want to run in --offline mode, because I want uvx to work normally. So I can write those scripts to not use --offline. However, when the index goes down, now I need to be running in --offline mode because a network failure doesn't automatically fallback to the local cache. That means I have to go edit all the callsites to use uvx --offline for that time period.
Example:
uvx ruff check fails when the package repo goes down and must be changed to uvx --offline ruff check to use the locally cached version of ruff. You have to have already run uvx ruff ... at least once with access to a package index to get it loaded into the cache for this to work but that's not something uv can fix 😆.
There are plenty of workarounds (such as maintaining a parallel set of scripts or accepting an "--offline" flag into the scripts) but this does seem like it could be behavior that uv/uvx could subsume.
I think this comes down to the fact that there's only two modes right now:
Online: Default, uvx always tries to reach out to the package registry. e.g. uv ruff format
Offline: --offline passed, uvx will never reach out to the package registry. e.g. uv --offline ruff format
I'm finding in my circumstances it would be great to have a third mode:
Online with Fallback: Act like the default however, if a network request fails, fall back to --offline type behavior for that dependency and check if it exists in the local cache. If it doesn't, then fail just like how uvx --offline <package not in cache> would fail. e.g. uv --offline-fallback ruff format.
While my circumstances are probably fairly niche, the general idea is to let uvx have a "best effort" in case it can't reach the package index and not just fail when there's a valid local cached version.
I'm not sure if there are any pitfalls you could end up in with what could be a mixed online/offline dependency resolution. You can think of some weird cases where a specific dependency has a git source defined and that's accessible but transitive dependencies aren't online because the package index is offline so they fallback to previously local cached versions. My first though is so long as the versions can be resolved satisfactorily it wouldn't be any different.
The text was updated successfully, but these errors were encountered:
alexjbuck
changed the title
uvx partial offline mode
uvx offline fallback mode
Jan 7, 2025
alexjbuck
changed the title
uvx offline fallback mode
uvx offline fallback mode?
Jan 7, 2025
This seems reasonable to me. I think the problem might be that we can't respect the registry's cache options? I'm not sure though, @charliermarsh would know better.
I do a lot of work in offline environments with an alternate package index. That index goes down sometimes (much more often than the public pypi repo would).
A lot of routine uv/uvx tasks will check against network locations before running unless the
--offline
flag is passed. When the index goes offline I can continue working with the--offline
flag anduv/uvx
will use its local cache. This is great!The issue is when I start having scripts or other tooling that invoke
uvx
. When the index is up, I don't want to run in--offline
mode, because I wantuvx
to work normally. So I can write those scripts to not use--offline
. However, when the index goes down, now I need to be running in--offline
mode because a network failure doesn't automatically fallback to the local cache. That means I have to go edit all the callsites to useuvx --offline
for that time period.Example:
uvx ruff check
fails when the package repo goes down and must be changed touvx --offline ruff check
to use the locally cached version of ruff. You have to have already runuvx ruff ...
at least once with access to a package index to get it loaded into the cache for this to work but that's not somethinguv
can fix 😆.There are plenty of workarounds (such as maintaining a parallel set of scripts or accepting an "--offline" flag into the scripts) but this does seem like it could be behavior that
uv/uvx
could subsume.I think this comes down to the fact that there's only two modes right now:
uvx
always tries to reach out to the package registry. e.g.uv ruff format
--offline
passed,uvx
will never reach out to the package registry. e.g.uv --offline ruff format
I'm finding in my circumstances it would be great to have a third mode:
--offline
type behavior for that dependency and check if it exists in the local cache. If it doesn't, then fail just like howuvx --offline <package not in cache>
would fail. e.g.uv --offline-fallback ruff format
.While my circumstances are probably fairly niche, the general idea is to let
uvx
have a "best effort" in case it can't reach the package index and not just fail when there's a valid local cached version.I'm not sure if there are any pitfalls you could end up in with what could be a mixed online/offline dependency resolution. You can think of some weird cases where a specific dependency has a
git
source defined and that's accessible but transitive dependencies aren't online because the package index is offline so they fallback to previously local cached versions. My first though is so long as the versions can be resolved satisfactorily it wouldn't be any different.The text was updated successfully, but these errors were encountered: