Lazily require some heavy files#8382
Conversation
323ea5f to
e649cf5
Compare
MikeMcQuaid
left a comment
There was a problem hiding this comment.
Nice if this speeds things up. My only thought/concern: how do we stop this happening again?
|
A test that makes sure |
Makes sense 👍🏻. |
|
Minor point that might not matter much: Is losing |
I don't think so.
I think it's nicer for |
Fine with me! Just wanted to make sure someone else agreed. |
fc0ecf7 to
8d51bec
Compare
|
It is using the v1-style cmd system (though with |
|
Remaining error is |
|
Thanks @Bo98! |
Fix: ``` /home/linuxbrew/.linuxbrew/Homebrew/Library/Taps/dawidd6/homebrew-test/Formula/test-formula-url.rb:2:in `<class:TestFormulaUrl>' /home/linuxbrew/.linuxbrew/Homebrew/Library/Taps/dawidd6/homebrew-test/Formula/test-formula-url.rb:1:in `load_formula' /home/linuxbrew/.linuxbrew/Homebrew/Library/Taps/homebrew/homebrew-livecheck/livecheck/extend/formulary.rb:22:in `module_eval' /home/linuxbrew/.linuxbrew/Homebrew/Library/Taps/homebrew/homebrew-livecheck/livecheck/extend/formulary.rb:22:in `load_formula' /home/linuxbrew/.linuxbrew/Homebrew/Library/Homebrew/formulary.rb:64:in `load_formula_from_path' /home/linuxbrew/.linuxbrew/Homebrew/Library/Homebrew/formulary.rb:149:in `load_file' /home/linuxbrew/.linuxbrew/Homebrew/Library/Homebrew/formulary.rb:294:in `load_file' /home/linuxbrew/.linuxbrew/Homebrew/Library/Homebrew/formulary.rb:139:in `klass' /home/linuxbrew/.linuxbrew/Homebrew/Library/Homebrew/formulary.rb:135:in `get_formula' /home/linuxbrew/.linuxbrew/Homebrew/Library/Homebrew/formulary.rb:284:in `get_formula' /home/linuxbrew/.linuxbrew/Homebrew/Library/Homebrew/formulary.rb:344:in `factory' /home/linuxbrew/.linuxbrew/Homebrew/Library/Homebrew/cli/named_args.rb:21:in `block in to_formulae' /home/linuxbrew/.linuxbrew/Homebrew/Library/Homebrew/cli/named_args.rb:20:in `map' /home/linuxbrew/.linuxbrew/Homebrew/Library/Homebrew/cli/named_args.rb:20:in `to_formulae' /home/linuxbrew/.linuxbrew/Homebrew/Library/Homebrew/cli/args.rb:60:in `formulae' /home/linuxbrew/.linuxbrew/Homebrew/Library/Taps/homebrew/homebrew-livecheck/cmd/livecheck.rb:94:in `livecheck' /home/linuxbrew/.linuxbrew/Homebrew/Library/Homebrew/brew.rb:119:in `<main>' Error: dawidd6/test/test-formula-url: undefined method `desc' for #<Class:0x000000000328e300> ``` After latest changes in `brew`: Homebrew/brew#8382
|
Using and this error occurs for any cask with a |
|
Thank you @Bo98, you were much faster than I was in spotting the problem! |
brew stylewith your changes locally?brew testswith your changes locally?The changes here are to avoid
require "formula"on a basic startup path (e.g.brew --version). This saves as much as 150ms in boot time.Parts of brew already did this, but it slowly stopped being the case over the years.
Notably:
cask/installerare among the heaviest in Homebrew.formulais now required inside Formulary'sload_formulamethod. This covers the vast majority of cases wererequire "formula"was needed.readallis now lazily loaded inTap#installas it has arequire "formula", likedescriptionsalready is for the same reason.