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

Pock SHA256 Mismatch #93794

Closed zgosalvez closed 3 years ago

zgosalvez commented 3 years ago

General troubleshooting steps

Description of issue

The file being downloaded by Homebrew is an HTML page, instead of the ZIP file, which is causing the checksum to fail. I confirmed that the ZIP file downloaded from the Cask's URL at https://pock.dev/download.php?file=pock_0_7_2.zip has the same SHA256 as the Cask. However, since Homebrew is downloading the URL as an HTML page, the checksum fails. In the outputs below, /Users/[redacted]/Library/Caches/Homebrew/downloads/0b5fce3a8e7ee8ddaff5e6f502882d42a209868ffc27334f4a0815bdfa2057db--file=pock_0_7_2.zip can be renamed to /Users/[redacted]/Library/Caches/Homebrew/downloads/0b5fce3a8e7ee8ddaff5e6f502882d42a209868ffc27334f4a0815bdfa2057db--file=pock_0_7_2.html, which shows the HTML page when you visit the URL in the web browser.

Command that failed

brew install --casks pock

Output of command with --verbose --debug

==> Cask::Installer#install
==> Printing caveats
==> Cask::Installer#fetch
==> Checking cask has checksum
==> Downloading
==> Downloading https://pock.dev/download.php?file=pock_0_7_2.zip
/usr/bin/curl --disable --globoff --show-error --user-agent Homebrew/2.5.12-275-gef75518\ \(Macintosh\;\ Intel\ Mac\ OS\ X\ 11.0.1\)\ curl/7.64.1 --header Accept-Language:\ en --retry 3 --location --silent --head --request GET https://pock.dev/download.php\?file=pock_0_7_2.zip
Already downloaded: /Users/[redacted]/Library/Caches/Homebrew/downloads/0b5fce3a8e7ee8ddaff5e6f502882d42a209868ffc27334f4a0815bdfa2057db--file=pock_0_7_2.zip
==> Checking quarantine support
/usr/bin/xattr
/usr/bin/swift /usr/local/Homebrew/Library/Homebrew/cask/utils/quarantine.swift
==> Quarantine is available.
==> Verifying Gatekeeper status of /Users/[redacted]/Library/Caches/Homebrew/downloads/0b5fce3a8e7ee8ddaff5e6f502882d42a209868ffc27334f4a0815bdfa2057db--file=pock_0_7_2.zip
/usr/bin/xattr -p com.apple.quarantine /Users/[redacted]/Library/Caches/Homebrew/downloads/0b5fce3a8e7ee8ddaff5e6f502882d42a209868ffc27334f4a0815bdfa2057db--file=pock_0_7_2.zip
==> /Users/[redacted]/Library/Caches/Homebrew/downloads/0b5fce3a8e7ee8ddaff5e6f502882d42a209868ffc27334f4a0815bdfa2057db--file=pock_0_7_2.zip is quarantined
==> Verifying checksum for cask 'pock'.
Error: SHA256 mismatch
Expected: 6b1e8047370d719407711c781c379ddf7e9eef572ed08407be0873ce4fe45476
  Actual: 547ce01017d64d3d502dbc1304f94b9f52c8559369e82777202b246a90a00e13
    File: /Users/[redacted]/Library/Caches/Homebrew/downloads/0b5fce3a8e7ee8ddaff5e6f502882d42a209868ffc27334f4a0815bdfa2057db--file=pock_0_7_2.zip
To retry an incomplete download, remove the file above.
/usr/local/Homebrew/Library/Homebrew/extend/pathname.rb:281:in `verify_checksum'
/usr/local/Homebrew/Library/Homebrew/cask/download.rb:59:in `verify_download_integrity'
/usr/local/Homebrew/Library/Homebrew/cask/download.rb:32:in `fetch'
/usr/local/Homebrew/Library/Homebrew/cask/installer.rb:157:in `download'
/usr/local/Homebrew/Library/Homebrew/cask/installer.rb:174:in `primary_container'
/usr/local/Homebrew/Library/Homebrew/cask/installer.rb:317:in `collect_cask_and_formula_dependencies'
/usr/local/Homebrew/Library/Homebrew/cask/installer.rb:344:in `cask_and_formula_dependencies'
/usr/local/Homebrew/Library/Homebrew/cask/installer.rb:253:in `satisfy_dependencies'
/usr/local/Homebrew/Library/Homebrew/cask/installer.rb:67:in `fetch'
/usr/local/Homebrew/Library/Homebrew/cask/installer.rb:94:in `install'
/usr/local/Homebrew/Library/Homebrew/cask/cmd/install.rb:79:in `block in install_casks'
/usr/local/Homebrew/Library/Homebrew/cask/cmd/install.rb:78:in `each'
/usr/local/Homebrew/Library/Homebrew/cask/cmd/install.rb:78:in `install_casks'
/usr/local/Homebrew/Library/Homebrew/cmd/install.rb:158:in `install'
/usr/local/Homebrew/Library/Homebrew/brew.rb:119: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
/usr/local/Homebrew/Library/Homebrew/vendor/bundle/bundler/../ruby/2.6.0/gems/sorbet-runtime-stub-0.2.0/lib
/usr/local/Homebrew/Library/Homebrew/vendor/bundle/bundler/../ruby/2.6.0/gems/ruby-macho-2.5.0/lib
/usr/local/Homebrew/Library/Homebrew/vendor/bundle/bundler/../ruby/2.6.0/gems/rubocop-sorbet-0.5.1/lib
/usr/local/Homebrew/Library/Homebrew/vendor/bundle/bundler/../ruby/2.6.0/gems/rubocop-rspec-2.0.0/lib
/usr/local/Homebrew/Library/Homebrew/vendor/bundle/bundler/../ruby/2.6.0/gems/rubocop-performance-1.9.0/lib
/usr/local/Homebrew/Library/Homebrew/vendor/bundle/bundler/../ruby/2.6.0/gems/ruby-progressbar-1.10.1/lib
/usr/local/Homebrew/Library/Homebrew/vendor/bundle/bundler/../ruby/2.6.0/gems/plist-3.5.0/lib
/usr/local/Homebrew/Library/Homebrew/vendor/bundle/bundler/../ruby/2.6.0/gems/patchelf-1.3.0/lib
/usr/local/Homebrew/Library/Homebrew/vendor/bundle/bundler/../ruby/2.6.0/gems/mechanize-2.7.6/lib
/usr/local/Homebrew/Library/Homebrew/vendor/bundle/bundler/../ruby/2.6.0/gems/elftools-1.1.3/lib
/usr/local/Homebrew/Library/Homebrew/vendor/bundle/bundler/
/usr/local/Homebrew/Library/Homebrew/vendor/bundle/bundler/../ruby/2.6.0/gems/bindata-2.4.8/lib
/usr/local/Homebrew/Library/Homebrew/vendor/bundle/bundler/../ruby/2.6.0/gems/activesupport-6.0.3.4/lib
/usr/local/Homebrew/Library/Homebrew/vendor/bundle/bundler/../ruby/2.6.0/gems/zeitwerk-2.4.1/lib
/usr/local/Homebrew/Library/Homebrew/vendor/bundle/bundler/../ruby/2.6.0/gems/tzinfo-1.2.8/lib
/usr/local/Homebrew/Library/Homebrew/vendor/bundle/bundler/../ruby/2.6.0/gems/thread_safe-0.3.6/lib
/usr/local/Homebrew/Library/Homebrew/vendor/bundle/bundler/../ruby/2.6.0/gems/i18n-1.8.5/lib
/usr/local/Homebrew/Library/Homebrew/vendor/bundle/bundler/../ruby/2.6.0/gems/concurrent-ruby-1.1.7/lib/concurrent-ruby
/Library/Ruby/Site/2.6.0
/Library/Ruby/Site/2.6.0/universal-darwin20
/Library/Ruby/Site
/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/universal-darwin20
/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/universal-darwin20
/usr/local/Homebrew/Library/Homebrew
==> Homebrew Version
2.5.12-275-gef75518
==> macOS
11.0.1
==> SIP
Enabled
==> Java
N/A
==> Homebrew Cask Staging Location
/usr/local/Caskroom
==> Homebrew Cask Taps:
/usr/local/Homebrew/Library/Taps/homebrew/homebrew-cask (3731 casks)
/usr/local/Homebrew/Library/Taps/zgosalvez/homebrew-repo (3 casks)
/usr/local/Homebrew/Library/Taps/homebrew/homebrew-cask-versions (167 casks)
/usr/local/Homebrew/Library/Taps/homebrew/homebrew-cask-fonts (1567 casks)
Your system is ready to brew.

Output of brew tap

homebrew/cask
homebrew/cask-fonts
homebrew/cask-versions
homebrew/core
zgosalvez/repo
miccal commented 3 years ago

I can confirm that https://pock.dev/download.php?file=pock_0_7_2.zip via a browser is fine, but via curl it downloads a corrupted .zip file that is in fact just a text/html file:

|-> curl -sLI https://pock.dev/download.php?file=pock_0_7_2.zip
HTTP/1.1 200 OK
Server: nginx
Date: Sat, 28 Nov 2020 07:38:42 GMT
Content-Type: text/html; charset=UTF-8
Connection: keep-alive

Not sure how to fix this?

zgosalvez commented 3 years ago

Not sure how to fix this?

@miccal, after perusing around with the HTML source, using the https://pock.dev/download.php?file=pock_0_7_2.zip&nw=1 works! Note: The working URL to download has the appended &nw=1 string.

miccal commented 3 years ago

Thank you for the report and the suggested fix @zgosalvez.

zgosalvez commented 3 years ago

My pleasure, @miccal. Thank you for the quick implementation.