Comments (5)
The solution for brew bump
is to require all loaded casks and formulae to be in installed taps. This pattern shows up in a few other places though and in those cases things should maybe be handled differently. It might not even be a problem if we know the cask will always have this field.
brew --cache
brew/Library/Homebrew/cmd/--cache.rb
Lines 72 to 82 in dfbf269
brew fetch
brew/Library/Homebrew/cmd/fetch.rb
Lines 161 to 168 in dfbf269
brew audit
brew/Library/Homebrew/dev-cmd/audit.rb
Lines 246 to 255 in dfbf269
brew bump-cask-pr
brew bump-cask-pr
Edit: This already gets checked for casks without associated taps which solves this problem.
brew/Library/Homebrew/dev-cmd/bump-cask-pr.rb
Line 129 in dfbf269
brew bump
brew/Library/Homebrew/dev-cmd/bump.rb
Line 356 in dfbf269
brew livecheck
from brew.
This is just one example of the problems that loading from installed cask files can cause.
It seems like we try to load casks using Cask::Cask#sourcefile_path as the ref and that causes problems sometimes because the source file path is nilable depending on which cask loader is used. We use this pattern in a few places to reload the same cask for different os/arch combinations. In this case, it was nil because it was loading the installed cask file instead of the one from the core cask repo.
I almost feel like there are some commands where we donโt want certain cask loaders to be used. Beyond that I wonder if weโd be able to catch this type of error beforehand with more typing in the Cask::Cask and Cask::CaskLoader classes.
-- Rescued from internal team slack
from brew.
It looks like what happens with a core formula when the core tap is not installed is that we load it from the keg and then use the path the installed formula file when reloading the formula for different architectures.
$ brew audit gawk --verbose --debug
/usr/local/Homebrew/Library/Homebrew/vendor/bundle/ruby/3.1.0/bin/bundle clean
/usr/local/Homebrew/Library/Homebrew/brew.rb (Formulary::FromKegLoader): loading gawk
/usr/local/Homebrew/Library/Homebrew/brew.rb (Cask::CaskLoader::NullLoader): loading gawk
/usr/local/Homebrew/Library/Homebrew/brew.rb (Formulary::FromKegLoader): loading gawk
/usr/local/Homebrew/Library/Homebrew/brew.rb (Cask::CaskLoader::NullLoader): loading gawk
/usr/bin/env XDG_CACHE_HOME=/Users/kevinrobell/Library/Caches/Homebrew/style /usr/local/Homebrew/Library/Homebrew/vendor/portable-ruby/3.1.4/bin/ruby -W1 --disable=gems,rubyopt -- /usr/local/Homebrew/Library/Homebrew/utils/rubocop.rb --format json --force-exclusion --parallel --extra-details --except FormulaAuditStrict --config /usr/local/Homebrew/Library/.rubocop.yml /usr/local/opt/gawk/.brew/gawk.rb
==> Auditing Formula gawk on os catalina and arch intel
/usr/local/Homebrew/Library/Homebrew/brew.rb (Formulary::FromPathLoader): loading /usr/local/opt/gawk/.brew/gawk.rb
/usr/local/Homebrew/Library/Homebrew/brew.rb (Formulary::FromAPILoader): loading gettext
/usr/local/Homebrew/Library/Homebrew/brew.rb (Formulary::FromAPILoader): loading mpfr
/usr/local/Homebrew/Library/Homebrew/brew.rb (Formulary::FromAPILoader): loading readline
/usr/local/Homebrew/Library/Homebrew/brew.rb (Formulary::FromAPILoader): loading curl
/usr/local/Homebrew/Library/Homebrew/brew.rb (Formulary::FromAPILoader): loading pkg-config
/usr/local/Homebrew/Library/Homebrew/brew.rb (Formulary::FromAPILoader): loading brotli
/usr/local/Homebrew/Library/Homebrew/brew.rb (Formulary::FromAPILoader): loading cmake
/usr/local/Homebrew/Library/Homebrew/brew.rb (Formulary::FromAPILoader): loading libidn2
/usr/local/Homebrew/Library/Homebrew/brew.rb (Formulary::FromAPILoader): loading libunistring
/usr/local/Homebrew/Library/Homebrew/brew.rb (Formulary::FromAPILoader): loading libnghttp2
/usr/local/Homebrew/Library/Homebrew/brew.rb (Formulary::FromAPILoader): loading libssh2
/usr/local/Homebrew/Library/Homebrew/brew.rb (Formulary::FromAPILoader): loading openssl@3
/usr/local/Homebrew/Library/Homebrew/brew.rb (Formulary::FromAPILoader): loading ca-certificates
/usr/local/Homebrew/Library/Homebrew/brew.rb (Formulary::FromAPILoader): loading openldap
/usr/local/Homebrew/Library/Homebrew/brew.rb (Formulary::FromAPILoader): loading rtmpdump
/usr/local/Homebrew/Library/Homebrew/brew.rb (Formulary::FromAPILoader): loading zstd
/usr/local/Homebrew/Library/Homebrew/brew.rb (Formulary::FromAPILoader): loading lz4
/usr/local/Homebrew/Library/Homebrew/brew.rb (Formulary::FromAPILoader): loading xz
/usr/local/Homebrew/Library/Homebrew/brew.rb (Formulary::FromAPILoader): loading gmp
We could easily make casks work the same way but I'm not sure it really captures the desired behavior of most of the dev commands. It'd still be an improvement though since it wouldn't fail loudly. In general, the livecheck
, bump*
and audit
commands assume the core taps are tapped locally.
Maybe we could add some way of turning off installed formula/cask file loading in the parser and then update Formulary.loader_for
and Cask::CaskLoader.for
to respect that.
from brew.
It'd still be an improvement though since it wouldn't fail loudly. In general, the
livecheck
,bump*
andaudit
commands assume the core taps are tapped locally.
Simplest/best case I think would be to make said commands exit (very) early if the relevant formula's tap is not tapped.
Maybe we could add some way of turning off installed formula/cask file loading in the parser and then update
Formulary.loader_for
andCask::CaskLoader.for
to respect that.
This seems like it might be a lot more complex than the prior option unless we somehow have some commands that need to load only from tap in some places but are fine with API in others.
from brew.
That makes sense to me. Looking at things a bit more, I see now that the bump-*-pr
commands already do that as of a few years ago. That approach should work well.
The fetch
and --cache
each have a lower likelihood of errors because they default to the name if the cask is loaded from the API which happens when loading from the installed cask JSON. Technically you could still see the same problem with casks installed from third-party taps though.
from brew.
Related Issues (20)
- Add `test` tag support for `resource`s HOT 1
- docs.brew.sh/Manpage does not wrap text properly on mobile HOT 3
- `brew migrate` doesn't recognise migrations to API taps HOT 3
- Verbose option stopped working (`-v` shows version, `--verbose` unknown command) HOT 3
- Allow casks to opt-in to forcibly quit during `brew upgrade` HOT 9
- Imposible update using WIFI HOT 3
- don't write .keepme in `bin` and `sbin` if it isn't needed HOT 1
- brew update --greedy: Parameter 'message': Expected type String, got type OptionParser::InvalidOption with value #<OptionParser::InvalidOption: --greedy> HOT 1
- `HOMEBREW_GITHUB_API_TOKEN` doesn't apply for call to `https://api.github.com/repos/org/name/releases/latest` HOT 2
- Homebrew formula has linkage issue on Apple silicon setup for python application with selenium as dependency HOT 5
- Support user set BUNDLE_USER_CACHE HOT 14
- Consider getting superenv from `/etc/profile` and `/etc/environment` HOT 5
- SBOMs break bottle reproducibility HOT 14
- Improve caveats handling for API installs HOT 8
- Migration to other tap broken HOT 9
- Replace PAT usage with GitHub App Tokens HOT 1
- Use `main` for Homebrew branches HOT 3
- Use Sorbet `typed: strict` in all (non-package) files in Homebrew organisation
- Attestation failure message emits secret HOT 1
- Spurious linkage errors to GCC on Linux HOT 7
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. ๐๐๐
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google โค๏ธ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from brew.