-
-
Notifications
You must be signed in to change notification settings - Fork 9.9k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
dependency_collector: fix caching of deps requiring brewed curl #16122
dependency_collector: fix caching of deps requiring brewed curl #16122
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Makes sense, thanks!
I wonder if the |
Yep, seems to work. Also added a case for |
941328e
to
dba8a14
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
if spec.is_a?(Resource) | ||
if spec.download_strategy <= CurlDownloadStrategy | ||
return "#{spec.download_strategy}#{File.extname(spec.url).split("?").first}" | ||
elsif spec.download_strategy <= VCSDownloadStrategy |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do we need the condition at all? Would this work?
elsif spec.download_strategy <= VCSDownloadStrategy | |
else |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It should if it's a safe assumption that any Resource will have a download strategy defined.
dba8a14
to
73c76a5
Compare
73c76a5
to
4b33460
Compare
Thanks @EricFromCanada, good catch! |
brew style
with your changes locally?brew typecheck
with your changes locally?brew tests
with your changes locally?This addresses a rather subtle dependency bug that's best illustrated with an example. If a formula's source needs brewed curl to be downloaded, it's marked as
using: :homebrew_curl
and will show curl as an implicit dependency.Same if the formula is a dependent for another.
But in some cases, curl isn't added as an implicit dependency when it should be.
In the above example, removing autoconf/automake/libtool will make curl show properly as a libzip dependency. So what's going on?
In #12296, I included a dirty workaround for the possibility that a resource requiring brewed curl to download (i.e. using
HomebrewCurlDownloadStrategy
) may also require another implicit dependency to open the downloaded file, which was to add curl directly to the dependency list with@deps << brewed_curl_dep_if_needed(tags)
, and then proceed with analyzing the URL as is done with the regularCurlDownloadStrategy
. The problem is that Dependency objects are cached. So, if a formula using e.g libzip (which is a .xz file) also depends on another formula which is the same file type (e.g. libtool, also a .xz file) and that dependency is processed first, the cache says that no implicit dependencies are required for this file type, causing the above code to be skipped.The fix is to 1) use a separate cache key for
HomebrewCurlDownloadStrategy
dependency objects, and 2) instead of inserting into@deps
directly, send multiple items back toadd()
and insert them there.