Homebrew / homebrew-cask

🍻 A CLI workflow for the administration of macOS applications distributed as binaries
https://brew.sh
BSD 2-Clause "Simplified" License
20.93k stars 10.71k forks source link

google-cloud-sdk installation fails with "definition is invalid: installer missing executable" #139715

Closed lucaong closed 1 year ago

lucaong commented 1 year ago

Verification

Description of issue

Installation of google-cloud-sdk with brew install --cask google-cloud-sdk fails with Error: Cask 'google-cloud-sdk' definition is invalid: installer missing executable.

It fails on this line of code: https://github.com/Homebrew/brew/blob/98999cc51033c6f1b2aae662024cba8544dcd3fd/Library/Homebrew/cask/artifact/installer.rb#L87

Indeed, at that point the path variable is nil, and inspecting args[:script] is:

{:args=>["--usage-reporting", "false", "--bash-completion", "false", "--path-update", "false", "--rc-path", "false", "--quiet", "--install-python", "false"]}

Which in fact misses the :executable property, even though it is given in https://github.com/Homebrew/homebrew-cask/blob/6c8f16cfda7fe1760877c479ffe304ac63f33749/Casks/google-cloud-sdk.rb#L13

Passing args[:script].dup instead of args[:script] to read_script_arguments on https://github.com/Homebrew/brew/blob/98999cc51033c6f1b2aae662024cba8544dcd3fd/Library/Homebrew/cask/artifact/installer.rb#L85 fixes the error, although it fails later with Error: It seems the symlink source '/opt/homebrew/Caskroom/google-cloud-sdk/latest/$(brew --prefix)/Caskroom/google-cloud-sdk/latest/google-cloud-sdk/completion.bash.inc' is not there.

Command that failed

brew install --cask google-cloud-sdk

Output of command with --verbose --debug

/opt/homebrew/Library/Homebrew/shims/shared/curl --disable --cookie /dev/null --globoff --show-error --user-agent Homebrew/3.6.19\ \(Macintosh\;\ arm64\ Mac\ OS\ X\ 13.1\)\ curl/7.85.0 --header Accept-Language:\ en --fail --max-time 5 --retry 3 --location --remote-time --output /Users/lucaongaro/Library/Caches/Homebrew/api/formula.json --time-cond /Users/lucaongaro/Library/Caches/Homebrew/api/formula.json --compressed --silent https://formulae.brew.sh/api/formula.json
/opt/homebrew/Library/Homebrew/shims/shared/curl --disable --cookie /dev/null --globoff --show-error --user-agent Homebrew/3.6.19\ \(Macintosh\;\ arm64\ Mac\ OS\ X\ 13.1\)\ curl/7.85.0 --header Accept-Language:\ en --max-time 5 --retry 3 --fail https://formulae.brew.sh/api/cask-source/google-cloud-sdk.rb
/opt/homebrew/Library/Homebrew/shims/shared/curl --disable --cookie /dev/null --globoff --show-error --user-agent Homebrew/3.6.19\ \(Macintosh\;\ arm64\ Mac\ OS\ X\ 13.1\)\ curl/7.85.0 --header Accept-Language:\ en --fail --max-time 5 --retry 3 --location --remote-time --output /Users/lucaongaro/Library/Caches/Homebrew/api/cask.json --time-cond /Users/lucaongaro/Library/Caches/Homebrew/api/cask.json --compressed --silent https://formulae.brew.sh/api/cask.json
==> Cask::Installer#install
==> Printing caveats
==> Caveats
To add gcloud components to your PATH, add this to your profile:

  for bash users
    source "$(brew --prefix)/Caskroom/google-cloud-sdk/latest/google-cloud-sdk/path.bash.inc"

  for zsh users
    source "$(brew --prefix)/Caskroom/google-cloud-sdk/latest/google-cloud-sdk/path.zsh.inc"

  for fish users
    source "$(brew --prefix)/Caskroom/google-cloud-sdk/latest/google-cloud-sdk/path.fish.inc"

==> Cask::Installer#fetch
==> Downloading https://dl.google.com/dl/cloudsdk/release/google-cloud-sdk.tar.gz
/opt/homebrew/Library/Homebrew/shims/shared/curl --disable --cookie /dev/null --globoff --show-error --user-agent Homebrew/3.6.19\ \(Macintosh\;\ arm64\ Mac\ OS\ X\ 13.1\)\ curl/7.85.0 --header Accept-Language:\ en --retry 3 --location --silent --head --request GET https://dl.google.com/dl/cloudsdk/release/google-cloud-sdk.tar.gz
Already downloaded: /Users/lucaongaro/Library/Caches/Homebrew/downloads/cda39f18c3069c1a4ac0cd5b1d91541af945cd331eba8443c58ec5c890343c0a--google-cloud-sdk.tar.gz
==> Checking quarantine support
/usr/bin/xattr -h
/usr/bin/swift -target arm64-apple-macosx13 /opt/homebrew/Library/Homebrew/cask/utils/quarantine.swift
==> Quarantine is available.
==> Verifying Gatekeeper status of /Users/lucaongaro/Library/Caches/Homebrew/downloads/cda39f18c3069c1a4ac0cd5b1d91541af945cd331eba8443c58ec5c890343c0a--google-cloud-sdk.tar.gz
/usr/bin/xattr -p com.apple.quarantine /Users/lucaongaro/Library/Caches/Homebrew/downloads/cda39f18c3069c1a4ac0cd5b1d91541af945cd331eba8443c58ec5c890343c0a--google-cloud-sdk.tar.gz
==> /Users/lucaongaro/Library/Caches/Homebrew/downloads/cda39f18c3069c1a4ac0cd5b1d91541af945cd331eba8443c58ec5c890343c0a--google-cloud-sdk.tar.gz is quarantined
Warning: No checksum defined for cask 'google-cloud-sdk', skipping verification.
/opt/homebrew/Library/Homebrew/brew.rb (Formulary::AliasAPILoader): loading python@3.10 from API
/opt/homebrew/Library/Homebrew/brew.rb (Formulary::FormulaAPILoader): loading gdbm from API
/opt/homebrew/Library/Homebrew/brew.rb (Formulary::FormulaAPILoader): loading mpdecimal from API
/opt/homebrew/Library/Homebrew/brew.rb (Formulary::FormulaAPILoader): loading openssl@1.1 from API
/opt/homebrew/Library/Homebrew/brew.rb (Formulary::FormulaAPILoader): loading readline from API
/opt/homebrew/Library/Homebrew/brew.rb (Formulary::FormulaAPILoader): loading sqlite from API
/opt/homebrew/Library/Homebrew/brew.rb (Formulary::FormulaAPILoader): loading xz from API
/opt/homebrew/Library/Homebrew/brew.rb (Formulary::FormulaAPILoader): loading ca-certificates from API
tar --list --file /Users/lucaongaro/Library/Caches/Homebrew/downloads/cda39f18c3069c1a4ac0cd5b1d91541af945cd331eba8443c58ec5c890343c0a--google-cloud-sdk.tar.gz
All formula dependencies satisfied.
==> Installing Cask google-cloud-sdk
==> Cask::Installer#stage
==> Extracting primary container
==> Using container class UnpackStrategy::Tar for /Users/lucaongaro/Library/Caches/Homebrew/downloads/cda39f18c3069c1a4ac0cd5b1d91541af945cd331eba8443c58ec5c890343c0a--google-cloud-sdk.tar.gz
tar --extract --no-same-owner --file /Users/lucaongaro/Library/Caches/Homebrew/downloads/cda39f18c3069c1a4ac0cd5b1d91541af945cd331eba8443c58ec5c890343c0a--google-cloud-sdk.tar.gz --directory /private/tmp/d20230118-16436-1lmocn
cp -pR /private/tmp/d20230118-16436-1lmocn/google-cloud-sdk/. /opt/homebrew/Caskroom/google-cloud-sdk/latest/google-cloud-sdk
chmod -Rf +w /private/tmp/d20230118-16436-1lmocn
==> Verifying Gatekeeper status of /Users/lucaongaro/Library/Caches/Homebrew/downloads/cda39f18c3069c1a4ac0cd5b1d91541af945cd331eba8443c58ec5c890343c0a--google-cloud-sdk.tar.gz
/usr/bin/xattr -p com.apple.quarantine /Users/lucaongaro/Library/Caches/Homebrew/downloads/cda39f18c3069c1a4ac0cd5b1d91541af945cd331eba8443c58ec5c890343c0a--google-cloud-sdk.tar.gz
==> /Users/lucaongaro/Library/Caches/Homebrew/downloads/cda39f18c3069c1a4ac0cd5b1d91541af945cd331eba8443c58ec5c890343c0a--google-cloud-sdk.tar.gz is quarantined
==> Propagating quarantine from /Users/lucaongaro/Library/Caches/Homebrew/downloads/cda39f18c3069c1a4ac0cd5b1d91541af945cd331eba8443c58ec5c890343c0a--google-cloud-sdk.tar.gz to /opt/homebrew/Caskroom/google-cloud-sdk/latest
/usr/bin/xattr -p com.apple.quarantine /Users/lucaongaro/Library/Caches/Homebrew/downloads/cda39f18c3069c1a4ac0cd5b1d91541af945cd331eba8443c58ec5c890343c0a--google-cloud-sdk.tar.gz
/usr/bin/xargs -0 -- /bin/chmod -h u\+w
/usr/bin/xargs -0 -- /usr/bin/xattr -w com.apple.quarantine 0381\;63c71d74\;\;C8A966C1-2121-41F5-87DE-9A11DDFCAB3B
Error: Cask 'google-cloud-sdk' definition is invalid: installer missing executable
/opt/homebrew/Library/Homebrew/cask/artifact/installer.rb:87:in `initialize'
/opt/homebrew/Library/Homebrew/cask/artifact/installer.rb:69:in `new'
/opt/homebrew/Library/Homebrew/cask/artifact/installer.rb:69:in `from_args'
/opt/homebrew/Library/Homebrew/cask/dsl.rb:348:in `block (2 levels) in <class:DSL>'
/opt/homebrew/Library/Homebrew/cask/cask_loader.rb:282:in `block (2 levels) in load'
/opt/homebrew/Library/Homebrew/cask/cask_loader.rb:277:in `each'
/opt/homebrew/Library/Homebrew/cask/cask_loader.rb:277:in `block in load'
/opt/homebrew/Library/Homebrew/cask/cask.rb:74:in `instance_eval'
/opt/homebrew/Library/Homebrew/cask/cask.rb:74:in `refresh'
/opt/homebrew/Library/Homebrew/cask/cask.rb:67:in `config='
/opt/homebrew/Library/Homebrew/cask/installer.rb:109:in `install'
/opt/homebrew/Library/Homebrew/cask/cmd/install.rb:112:in `block in install_casks'
/opt/homebrew/Library/Homebrew/cask/cmd/install.rb:111:in `each'
/opt/homebrew/Library/Homebrew/cask/cmd/install.rb:111:in `install_casks'
/opt/homebrew/Library/Homebrew/cmd/install.rb:189:in `install'
/opt/homebrew/Library/Homebrew/brew.rb:98:in `<main>'

Output of brew doctor --verbose

==> Cask Environment Variables:
BUNDLE_PATH
CHRUBY_VERSION
GEM_HOME
GEM_PATH
HOMEBREW_CASK_OPTS
LC_ALL
PATH
RBENV_VERSION
RUBYLIB
RUBYOPT
RUBYPATH
SHELL
==> $LOAD_PATHS
/opt/homebrew/Library/Homebrew/vendor/bundle/ruby/2.6.0/gems/warning-1.3.0/lib
/opt/homebrew/Library/Homebrew/vendor/bundle/ruby/2.6.0/gems/tapioca-0.7.3/lib
/opt/homebrew/Library/Homebrew/vendor/bundle/ruby/2.6.0/gems/yard-sorbet-0.6.1/lib
/opt/homebrew/Library/Homebrew/vendor/bundle/ruby/2.6.0/gems/yard-0.9.28/lib
/opt/homebrew/Library/Homebrew/vendor/bundle/ruby/2.6.0/gems/spoom-1.1.11/lib
/opt/homebrew/Library/Homebrew/vendor/bundle/ruby/2.6.0/gems/thor-1.2.1/lib
/opt/homebrew/Library/Homebrew/vendor/bundle/ruby/2.6.0/gems/sorbet-static-and-runtime-0.5.10461/lib
/opt/homebrew/Library/Homebrew/vendor/bundle/ruby/2.6.0/gems/sorbet-0.5.10461/lib
/opt/homebrew/Library/Homebrew/vendor/bundle/ruby/2.6.0/gems/sorbet-static-0.5.10461-universal-darwin-21/lib
/opt/homebrew/Library/Homebrew/vendor/bundle/ruby/2.6.0/gems/simplecov-cobertura-2.1.0/lib
/opt/homebrew/Library/Homebrew/vendor/bundle/ruby/2.6.0/gems/simplecov-0.22.0/lib
/opt/homebrew/Library/Homebrew/vendor/bundle/ruby/2.6.0/gems/simplecov_json_formatter-0.1.4/lib
/opt/homebrew/Library/Homebrew/vendor/bundle/ruby/2.6.0/gems/simplecov-html-0.12.3/lib
/opt/homebrew/Library/Homebrew/vendor/bundle/ruby/2.6.0/gems/ruby-macho-3.0.0/lib
/opt/homebrew/Library/Homebrew/vendor/bundle/ruby/2.6.0/gems/rubocop-sorbet-0.6.11/lib
/opt/homebrew/Library/Homebrew/vendor/bundle/ruby/2.6.0/gems/rubocop-rspec-2.17.0/lib
/opt/homebrew/Library/Homebrew/vendor/bundle/ruby/2.6.0/gems/rubocop-rails-2.17.4/lib
/opt/homebrew/Library/Homebrew/vendor/bundle/ruby/2.6.0/gems/rubocop-performance-1.15.2/lib
/opt/homebrew/Library/Homebrew/vendor/bundle/ruby/2.6.0/gems/rubocop-1.43.0/lib
/opt/homebrew/Library/Homebrew/vendor/bundle/ruby/2.6.0/gems/unicode-display_width-2.4.2/lib
/opt/homebrew/Library/Homebrew/vendor/bundle/ruby/2.6.0/gems/ruby-progressbar-1.11.0/lib
/opt/homebrew/Library/Homebrew/vendor/bundle/ruby/2.6.0/gems/rubocop-ast-1.24.1/lib
/opt/homebrew/Library/Homebrew/vendor/bundle/ruby/2.6.0/gems/rspec_junit_formatter-0.6.0/lib
/opt/homebrew/Library/Homebrew/vendor/bundle/ruby/2.6.0/gems/rspec-wait-0.0.9/lib
/opt/homebrew/Library/Homebrew/vendor/bundle/ruby/2.6.0/gems/rspec-sorbet-1.9.1/lib
/opt/homebrew/Library/Homebrew/vendor/bundle/ruby/2.6.0/gems/rspec-retry-0.6.2/lib
/opt/homebrew/Library/Homebrew/vendor/bundle/ruby/2.6.0/gems/rspec-its-1.3.0/lib
/opt/homebrew/Library/Homebrew/vendor/bundle/ruby/2.6.0/gems/rspec-github-2.4.0/lib
/opt/homebrew/Library/Homebrew/vendor/bundle/ruby/2.6.0/gems/rspec-3.12.0/lib
/opt/homebrew/Library/Homebrew/vendor/bundle/ruby/2.6.0/gems/rspec-mocks-3.12.2/lib
/opt/homebrew/Library/Homebrew/vendor/bundle/ruby/2.6.0/gems/rspec-expectations-3.12.2/lib
/opt/homebrew/Library/Homebrew/vendor/bundle/ruby/2.6.0/gems/rspec-core-3.12.0/lib
/opt/homebrew/Library/Homebrew/vendor/bundle/ruby/2.6.0/gems/rspec-support-3.12.0/lib
/opt/homebrew/Library/Homebrew/vendor/bundle/ruby/2.6.0/gems/ronn-0.7.3/lib
/opt/homebrew/Library/Homebrew/vendor/bundle/ruby/2.6.0/gems/rexml-3.2.5/lib
/opt/homebrew/Library/Homebrew/vendor/bundle/ruby/2.6.0/gems/rdiscount-2.2.7/lib
/opt/homebrew/Library/Homebrew/vendor/bundle/ruby/2.6.0/extensions/universal-darwin-21/2.6.0/rdiscount-2.2.7
/opt/homebrew/Library/Homebrew/vendor/bundle/ruby/2.6.0/gems/rbi-0.0.14/lib
/opt/homebrew/Library/Homebrew/vendor/bundle/ruby/2.6.0/gems/unparser-0.6.4/lib
/opt/homebrew/Library/Homebrew/vendor/bundle/ruby/2.6.0/gems/rack-3.0.3/lib
/opt/homebrew/Library/Homebrew/vendor/bundle/ruby/2.6.0/gems/pry-0.14.2/lib
/opt/homebrew/Library/Homebrew/vendor/bundle/ruby/2.6.0/gems/plist-3.6.0/lib
/opt/homebrew/Library/Homebrew/vendor/bundle/ruby/2.6.0/gems/patchelf-1.4.0/lib
/opt/homebrew/Library/Homebrew/vendor/bundle/ruby/2.6.0/gems/parlour-8.1.0/lib
/opt/homebrew/Library/Homebrew/vendor/bundle/ruby/2.6.0/gems/sorbet-runtime-0.5.10461/lib
/opt/homebrew/Library/Homebrew/vendor/bundle/ruby/2.6.0/gems/rainbow-3.1.1/lib
/opt/homebrew/Library/Homebrew/vendor/bundle/ruby/2.6.0/gems/parser-3.2.0.0/lib
/opt/homebrew/Library/Homebrew/vendor/bundle/ruby/2.6.0/gems/parallel_tests-3.13.0/lib
/opt/homebrew/Library/Homebrew/vendor/bundle/ruby/2.6.0/gems/parallel-1.22.1/lib
/opt/homebrew/Library/Homebrew/vendor/bundle/ruby/2.6.0/gems/mustache-1.1.1/lib
/opt/homebrew/Library/Homebrew/vendor/bundle/ruby/2.6.0/gems/method_source-1.0.0/lib
/opt/homebrew/Library/Homebrew/vendor/bundle/ruby/2.6.0/gems/mechanize-2.8.5/lib
/opt/homebrew/Library/Homebrew/vendor/bundle/ruby/2.6.0/gems/webrobots-0.1.2/lib
/opt/homebrew/Library/Homebrew/vendor/bundle/ruby/2.6.0/gems/webrick-1.7.0/lib
/opt/homebrew/Library/Homebrew/vendor/bundle/ruby/2.6.0/gems/rubyntlm-0.6.3/lib
/opt/homebrew/Library/Homebrew/vendor/bundle/ruby/2.6.0/gems/nokogiri-1.13.10-x86_64-darwin/lib
/opt/homebrew/Library/Homebrew/vendor/bundle/ruby/2.6.0/gems/racc-1.6.2/lib
/opt/homebrew/Library/Homebrew/vendor/bundle/ruby/2.6.0/extensions/universal-darwin-21/2.6.0/racc-1.6.2
/opt/homebrew/Library/Homebrew/vendor/bundle/ruby/2.6.0/gems/net-http-persistent-4.0.1/lib
/opt/homebrew/Library/Homebrew/vendor/bundle/ruby/2.6.0/gems/net-http-digest_auth-1.4.1/lib
/opt/homebrew/Library/Homebrew/vendor/bundle/ruby/2.6.0/gems/mime-types-3.4.1/lib
/opt/homebrew/Library/Homebrew/vendor/bundle/ruby/2.6.0/gems/mime-types-data-3.2022.0105/lib
/opt/homebrew/Library/Homebrew/vendor/bundle/ruby/2.6.0/gems/json_schemer-0.2.24/lib
/opt/homebrew/Library/Homebrew/vendor/bundle/ruby/2.6.0/gems/uri_template-0.7.0/lib
/opt/homebrew/Library/Homebrew/vendor/bundle/ruby/2.6.0/gems/json-2.6.3/lib
/opt/homebrew/Library/Homebrew/vendor/bundle/ruby/2.6.0/extensions/universal-darwin-21/2.6.0/json-2.6.3
/opt/homebrew/Library/Homebrew/vendor/bundle/ruby/2.6.0/gems/http-cookie-1.0.5/lib
/opt/homebrew/Library/Homebrew/vendor/bundle/ruby/2.6.0/gems/hpricot-0.8.6/lib
/opt/homebrew/Library/Homebrew/vendor/bundle/ruby/2.6.0/extensions/universal-darwin-21/2.6.0/hpricot-0.8.6
/opt/homebrew/Library/Homebrew/vendor/bundle/ruby/2.6.0/gems/hana-1.3.7/lib
/opt/homebrew/Library/Homebrew/vendor/bundle/ruby/2.6.0/gems/elftools-1.2.0/lib
/opt/homebrew/Library/Homebrew/vendor/bundle/ruby/2.6.0/gems/ecma-re-validator-0.4.0/lib
/opt/homebrew/Library/Homebrew/vendor/bundle/ruby/2.6.0/gems/regexp_parser-2.6.1/lib
/opt/homebrew/Library/Homebrew/vendor/bundle/ruby/2.6.0/gems/domain_name-0.5.20190701/lib
/opt/homebrew/Library/Homebrew/vendor/bundle/ruby/2.6.0/gems/unf-0.1.4/lib
/opt/homebrew/Library/Homebrew/vendor/bundle/ruby/2.6.0/gems/unf_ext-0.0.8.2/lib
/opt/homebrew/Library/Homebrew/vendor/bundle/ruby/2.6.0/extensions/universal-darwin-21/2.6.0/unf_ext-0.0.8.2
/opt/homebrew/Library/Homebrew/vendor/bundle/ruby/2.6.0/gems/docile-1.4.0/lib
/opt/homebrew/Library/Homebrew/vendor/bundle/ruby/2.6.0/gems/diff-lcs-1.5.0/lib
/opt/homebrew/Library/Homebrew/vendor/bundle/ruby/2.6.0/gems/did_you_mean-1.6.3/lib
/opt/homebrew/Library/Homebrew/vendor/bundle/ruby/2.6.0/gems/connection_pool-2.3.0/lib
/opt/homebrew/Library/Homebrew/vendor/bundle/ruby/2.6.0/gems/commander-4.6.0/lib
/opt/homebrew/Library/Homebrew/vendor/bundle/ruby/2.6.0/gems/highline-2.0.3/lib
/opt/homebrew/Library/Homebrew/vendor/bundle/ruby/2.6.0/gems/coderay-1.1.3/lib
/opt/homebrew/Library/Homebrew/vendor/bundle/ruby/2.6.0/gems/byebug-11.1.3/lib
/opt/homebrew/Library/Homebrew/vendor/bundle/ruby/2.6.0/extensions/universal-darwin-21/2.6.0/byebug-11.1.3
/opt/homebrew/Library/Homebrew/vendor/bundle/ruby/2.6.0/gems/bootsnap-1.15.0/lib
/opt/homebrew/Library/Homebrew/vendor/bundle/ruby/2.6.0/extensions/universal-darwin-21/2.6.0/bootsnap-1.15.0
/opt/homebrew/Library/Homebrew/vendor/bundle/ruby/2.6.0/gems/msgpack-1.6.0/lib
/opt/homebrew/Library/Homebrew/vendor/bundle/ruby/2.6.0/extensions/universal-darwin-21/2.6.0/msgpack-1.6.0
/opt/homebrew/Library/Homebrew/vendor/bundle/ruby/2.6.0/gems/bindata-2.4.14/lib
/opt/homebrew/Library/Homebrew/vendor/bundle/ruby/2.6.0/gems/ast-2.4.2/lib
/opt/homebrew/Library/Homebrew/vendor/bundle/ruby/2.6.0/gems/addressable-2.8.1/lib
/opt/homebrew/Library/Homebrew/vendor/bundle/ruby/2.6.0/gems/public_suffix-5.0.1/lib
/opt/homebrew/Library/Homebrew/vendor/bundle/ruby/2.6.0/gems/activesupport-6.1.7/lib
/opt/homebrew/Library/Homebrew/vendor/bundle/ruby/2.6.0/gems/zeitwerk-2.6.6/lib
/opt/homebrew/Library/Homebrew/vendor/bundle/ruby/2.6.0/gems/tzinfo-2.0.5/lib
/opt/homebrew/Library/Homebrew/vendor/bundle/ruby/2.6.0/gems/minitest-5.17.0/lib
/opt/homebrew/Library/Homebrew/vendor/bundle/ruby/2.6.0/gems/i18n-1.12.0/lib
/opt/homebrew/Library/Homebrew/vendor/bundle/ruby/2.6.0/gems/concurrent-ruby-1.1.10/lib/concurrent-ruby
/System/Library/Frameworks/Ruby.framework/Versions/2.6/usr/lib/ruby/vendor_ruby/2.6.0
/System/Library/Frameworks/Ruby.framework/Versions/2.6/usr/lib/ruby/vendor_ruby/2.6.0/arm64e-darwin22
/System/Library/Frameworks/Ruby.framework/Versions/2.6/usr/lib/ruby/vendor_ruby/2.6.0/universal-darwin22
/System/Library/Frameworks/Ruby.framework/Versions/2.6/usr/lib/ruby/vendor_ruby
/System/Library/Frameworks/Ruby.framework/Versions/2.6/usr/lib/ruby/2.6.0
/System/Library/Frameworks/Ruby.framework/Versions/2.6/usr/lib/ruby/2.6.0/arm64e-darwin22
/System/Library/Frameworks/Ruby.framework/Versions/2.6/usr/lib/ruby/2.6.0/universal-darwin22
/opt/homebrew/Library/Homebrew
==> Homebrew Version
3.6.19-dirty
==> macOS
13.1
==> SIP
Enabled
==> Homebrew Cask Staging Location
/opt/homebrew/Caskroom
==> Homebrew Cask Taps:
/opt/homebrew/Library/Taps/homebrew/homebrew-cask (0 casks)
Please note that these warnings are just used to help the Homebrew maintainers
with debugging if you file an issue. If everything you use Homebrew for is
working fine: please don't worry or file an issue; just ignore this. Thanks!

Warning: You have unlinked kegs in your Cellar.
Leaving kegs unlinked can lead to build-trouble and cause formulae that depend on
those kegs to fail to run properly once built. Run `brew link` on these:
  sheesy

Output of brew tap

homebrew/core
share-secrets-safely/cli
lucaong commented 1 year ago

A couple of findings: as written above, the original issue is fixed by passing args[:script].dup instead of args[:script] to read_script_arguments on https://github.com/Homebrew/brew/blob/98999cc51033c6f1b2aae662024cba8544dcd3fd/Library/Homebrew/cask/artifact/installer.rb#L85 . It looks like read_script_arguments mutates the argument passed to it, removing the :executable entry from the hash. Somehow the code path when installing google-cloud-sdk calls read_script_arguments twice, so the second time the :executable property is missing.

Once that original problem is fixed though, the formula breaks with a different error:

Error: It seems the symlink source '/opt/homebrew/Caskroom/google-cloud-sdk/latest/$(brew --prefix)/Caskroom/google-cloud-sdk/latest/google-cloud-sdk/completion.bash.inc' is not there.

The problem this time is in the formula: this line and this line should not prepend staged_path to the source path. The source method of Cask::Artifact::Relocated already takes care of prepending the staged_path here, so the resulting source ends up containing the staged_path twice.

I am not sure why the issue popped up now with google-cloud-sdk, and if the formula used to work before. Someone more familiar with the codebase should probably review my findings. If adding dup and fixing the symlink paths in the formula are acceptable solutions, I am happy to send two PRs.

lucaong commented 1 year ago

Interestingly, by only fixing the symlink sources in the formula, the original bug disappears. I created a pull request to fix the formula, that resolves this issue: https://github.com/Homebrew/homebrew-cask/pull/139749

aaronhipple commented 1 year ago

I'm still seeing this.

I've run through

And I confirmed with brew edit google-cloud-sdk that I have the change from #139749 locally. I still had to make this change

Passing args[:script].dup instead of args[:script] to read_script_arguments on https://github.com/Homebrew/brew/blob/98999cc51033c6f1b2aae662024cba8544dcd3fd/Library/Homebrew/cask/artifact/installer.rb#L85 fixes the error

to resolve. Several coworkers are reporting the same.

@miccal I see you've closed this issue - would you prefer we file a new one or reopen this one? I can provide further details in little bit, but my output from --verbose --debug and brew doctor is essentially the same as the original ticket.

lucaong commented 1 year ago

Using .dup or otherwise avoiding mutating args[:script] in place is anyway a good idea in my opinion, to avoid these sort of bugs in case this code path is invoked twice. I am not sure if the update in place was done on purpose for performance reasons, but I would expect that the impact is negligible.

lucaong commented 1 year ago

@miccal @aaronhipple I sent this pull request to address it.