Skip to content

Conversation

@terror
Copy link
Contributor

@terror terror commented Dec 4, 2025

Resolves #16974

This diff consults the cache’s freshness policy before reusing a cached tool environment, so --refresh (and package-specific refresh flags) actually invalidate stale envs instead of silently reusing them. Previously, local projects with unchanged versions kept running old code because the cached env was always treated as fresh; the change implemented here forces a rebuild when refresh is requested.

if let Ok(root) = cache.resolve_link(cache_entry.path()) {
if let Ok(environment) = PythonEnvironment::from_root(root, cache) {
return Ok(Self(environment));
if cache.freshness(&cache_entry, None, None)?.is_fresh() {
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Previous errors were swallowed here... I'm thinking we should do the same for the freshness check? 🤔

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What causes the freshness check to fail? is_ok_and could be fine 🤷‍♀️ but it depends on the failure conditions

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Permission denied or other I/O related errors when reading the cache entry's metadata could occur. These are probably rare edge cases, and if we can't even read the metadata of a cache entry, falling through to rebuild seems reasonable to me.

@terror
Copy link
Contributor Author

terror commented Dec 4, 2025

@zanieb Thinking about this change more (after looking at a few existing tests), it looks like re-using the cache for --refresh was deliberate? I can see this as an optimization for registry packages, but it kind of breaks down for local path dependencies. I would assume that users expect --refresh to give them fresh results everytime, so we're essentially prioritizing correctness over the existing optimization here.

@zanieb
Copy link
Member

zanieb commented Dec 4, 2025

I think @charliermarsh probably has the most context on the existing behavior.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Can't convince uvx to update program from a local project

2 participants