Homebrew / brew

🍺 The missing package manager for macOS (or Linux)
https://brew.sh
BSD 2-Clause "Simplified" License
41.43k stars 9.74k forks source link

`bump-cask-pr`: incorrectly fetches HTML when using POST request #11645

Closed cho-m closed 3 years ago

cho-m commented 3 years ago

brew config output

HOMEBREW_VERSION: 3.2.0-126-g83aa3ff
ORIGIN: https://github.com/Homebrew/brew
HEAD: 83aa3ff258438558f44ab95d76b352abf5d6e3a3
Last commit: 30 hours ago
Core tap ORIGIN: https://github.com/Homebrew/homebrew-core
Core tap HEAD: bef2808371d9fca2ad9922f43b71f607b8e0b6b7
Core tap last commit: 44 minutes ago
Core tap branch: master
HOMEBREW_PREFIX: /opt/homebrew
HOMEBREW_BAT: set
HOMEBREW_BAT_CONFIG_PATH: /Users/cho-m/.config/bat/config
HOMEBREW_CASK_OPTS: []
HOMEBREW_EDITOR: nvim
HOMEBREW_GITHUB_API_TOKEN: set
HOMEBREW_MAKE_JOBS: 8
HOMEBREW_NO_INSECURE_REDIRECT: set
Homebrew Ruby: 2.6.3 => /System/Library/Frameworks/Ruby.framework/Versions/2.6/usr/bin/ruby
CPU: octa-core 64-bit arm_firestorm_icestorm
Clang: 12.0.5 build 1205
Git: 2.32.0 => /opt/homebrew/bin/git
Curl: 7.64.1 => /usr/bin/curl
macOS: 11.4-arm64
CLT: 12.5.0.22.9
Xcode: 12.5.1
Rosetta 2: false

brew doctor output

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: "config" scripts exist outside your system or Homebrew directories.
`./configure` scripts often look for *-config scripts to determine if
software packages are installed, and which additional flags to use when
compiling and linking.

Having additional scripts in your path can confuse software installed via
Homebrew if the config script overrides a system or Homebrew-provided
script of the same name. We found the following "config" scripts:
  /Users/cho-m/.local/share/cargo/bin/cargo-install-update-config
  /Users/cho-m/.local/share/asdf/shims/python3.9-config
  /Users/cho-m/.local/share/asdf/shims/python-config
  /Users/cho-m/.local/share/asdf/shims/python3-config

What were you trying to do (and why)?

brew bump-cask-pr segger-jlink --version 7.50 to update to latest version from livecheck.

What happened (include all command output)?

The PR was created with incorrect sha256 checksums. I think this is related to download URL using: :post, which may not be correctly processed by bump-cask-pr

Issue originally mentioned in older PR: https://github.com/Homebrew/homebrew-cask-drivers/pull/2197#issuecomment-834666095 Also seen in PR I created: Homebrew/homebrew-cask-drivers#2308

Corresponding curl commands used by bump-cask-pr:

❯ brew bump-cask-pr segger-jlink --write --version 7.50 --debug --verbose
/opt/homebrew/Library/Homebrew/shims/scm/git --version
/usr/bin/curl --disable --globoff --show-error --user-agent Homebrew/3.2.0-126-g83aa3ff\ \(Macintosh\;\ arm64\ Mac\ OS\ X\ 11.4\)\ curl/7.64.1 --header Accept-Language:\ en --retry 3 --location https://api.github.com/search/issues\?q=segger-jlink\+repo\%3AHomebrew\%2Fhomebrew-cask-drivers\+state\%3Aopen\+in\%3Atitle\&per_page=100 --header Accept:\ application/vnd.github.v3\+json --write-out '
'\%\{http_code\} --header Accept:\ application/vnd.github.antiope-preview\+json --header Authorization:\ token\ ****** --dump-header /private/tmp/github_api_headers20210703-39049-1umsz4n
/usr/bin/curl --disable --globoff --show-error --user-agent Homebrew/3.2.0-126-g83aa3ff\ \(Macintosh\;\ arm64\ Mac\ OS\ X\ 11.4\)\ curl/7.64.1 --header Accept-Language:\ en --retry 3 --location --silent --head --request GET https://www.segger.com/downloads/jlink/JLink_MacOSX_V750_arm64.pkg
==> Downloading https://www.segger.com/downloads/jlink/JLink_MacOSX_V750_arm64.pkg
/usr/bin/curl --disable --globoff --show-error --user-agent Homebrew/3.2.0-126-g83aa3ff\ \(Macintosh\;\ arm64\ Mac\ OS\ X\ 11.4\)\ curl/7.64.1 --header Accept-Language:\ en --retry 3 --location --head https://www.segger.com/downloads/jlink/JLink_MacOSX_V750_arm64.pkg
/usr/bin/curl --disable --globoff --show-error --user-agent Homebrew/3.2.0-126-g83aa3ff\ \(Macintosh\;\ arm64\ Mac\ OS\ X\ 11.4\)\ curl/7.64.1 --header Accept-Language:\ en --fail --retry 3 --location --remote-time --output /Users/cho-m/Library/Caches/Homebrew/downloads/05bacd6cc3fffa3bc05f04c574f55c8f1482b4e7dfd421c263f42dc0247a7fae--JLink_MacOSX_V750_arm64.pkg.incomplete https://www.segger.com/downloads/jlink/JLink_MacOSX_V750_arm64.pkg
...

Check that file is actually an HTML and not a PKG:

❯ file ~/Library/Caches/Homebrew/downloads/*JLink*
/Users/cho-m/Library/Caches/Homebrew/downloads/05bacd6cc3fffa3bc05f04c574f55c8f1482b4e7dfd421c263f42dc0247a7fae--JLink_MacOSX_V750_arm64.pkg:  HTML document text, UTF-8 Unicode text, with very long lines, with CRLF, LF line terminators
/Users/cho-m/Library/Caches/Homebrew/downloads/421fe1f9e254bc5f6f2dfa62701a74c8941a83291269c253274c5493fa045d71--JLink_MacOSX_V750_x86_64.pkg: HTML document text, UTF-8 Unicode text, with very long lines, with CRLF, LF line terminators

And brew fetch showing incorrect checksum:

❯ brew fetch --cask --force segger-jlink --debug --verbose
==> Downloading https://www.segger.com/downloads/jlink/JLink_MacOSX_V750_arm64.pkg
/usr/bin/curl --disable --globoff --show-error --user-agent Homebrew/3.2.0-126-g83aa3ff\ \(Macintosh\;\ arm64\ Mac\ OS\ X\ 11.4\)\ curl/7.64.1 --header Accept-Language:\ en --retry 3 --location --silent --head --request GET https://www.segger.com/downloads/jlink/JLink_MacOSX_V750_arm64.pkg
/usr/bin/curl --disable --globoff --show-error --user-agent Homebrew/3.2.0-126-g83aa3ff\ \(Macintosh\;\ arm64\ Mac\ OS\ X\ 11.4\)\ curl/7.64.1 --header Accept-Language:\ en --retry 3 --location --head https://www.segger.com/downloads/jlink/JLink_MacOSX_V750_arm64.pkg -d accept_license_agreement=accepted -d non_emb_ctr=confirmed -d submit=Download\+software
/usr/bin/curl --disable --globoff --show-error --user-agent Homebrew/3.2.0-126-g83aa3ff\ \(Macintosh\;\ arm64\ Mac\ OS\ X\ 11.4\)\ curl/7.64.1 --header Accept-Language:\ en --fail --retry 3 --location --remote-time --output /Users/cho-m/Library/Caches/Homebrew/downloads/05bacd6cc3fffa3bc05f04c574f55c8f1482b4e7dfd421c263f42dc0247a7fae--JLink_MacOSX_V750_arm64.pkg.incomplete https://www.segger.com/downloads/jlink/JLink_MacOSX_V750_arm64.pkg -d accept_license_agreement=accepted -d non_emb_ctr=confirmed -d submit=Download\+software

...

==> Verifying checksum for cask 'segger-jlink'
Warning: Cask reports different sha256: 33b8f9014cee6e19ae10539ddc267788ecb365ac6a73cb3d926c8fe526fb45b0

What did you expect to happen?

Create PR with correct sha256 checksums.

Step-by-step reproduction instructions (by running brew commands)

brew bump-cask-pr segger-jlink --write --version 7.50
brew fetch --cask --force segger-jlink
github-actions[bot] commented 3 years ago

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs.

MikeMcQuaid commented 3 years ago

@cho-m Please don't self-reopen stalebot closed issues unless you or another maintainer is actively committed to fixing them in the nearish future.

github-actions[bot] commented 3 years ago

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs.

cho-m commented 3 years ago

I'll take a look into this to see if possible to use brew fetch --cask logic.