Homebrew / brew

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

JSON Livecheck fails, curl: (22) The requested URL returned error: 404 #14888

Closed mietzen closed 1 year ago

mietzen commented 1 year ago

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: Some installed kegs have no formulae!
This means they were either deleted or installed manually.
You should find replacements for the following formulae:
  szip

Warning: Some installed formulae are deprecated or disabled.
You should find replacements for the following formulae:
  elinks
  hdf5@1.8

Warning: You have uncommitted modifications to Homebrew/homebrew-core.
If this is a surprise to you, then you should stash these modifications.
Stashing returns Homebrew to a pristine state but can be undone
should you later need to do so for some reason.
  cd /opt/homebrew/Library/Taps/homebrew/homebrew-core && git stash -u && git clean -d -f

Uncommitted files:
   M Formula/ext4fuse.rb
   M Formula/sshfs.rb

Verification

brew config output

HOMEBREW_VERSION: 4.0.4-196-g180c89e
ORIGIN: https://github.com/Homebrew/brew
HEAD: 180c89e17426d4fb1562ac1b2bbe0c4c6e1a3cec
Last commit: 27 hours ago
Core tap origin: https://github.com/Homebrew/homebrew-core
Core tap HEAD: 2f7330fe49b9138a13e952ba9aeb2f2051902e3c
Core tap last commit: 5 weeks ago
Core tap branch: master
Core tap JSON: 05 Mar 08:28 UTC
HOMEBREW_PREFIX: /opt/homebrew
HOMEBREW_CASK_OPTS: ["--no-quarantine"]
HOMEBREW_EDITOR: nano
HOMEBREW_MAKE_JOBS: 10
Homebrew Ruby: 2.6.8 => /opt/homebrew/Library/Homebrew/vendor/portable-ruby/2.6.8_1/bin/ruby
CPU: 10-core 64-bit arm_firestorm_icestorm
Clang: 14.0.0 build 1400
Git: 2.39.2 => /opt/homebrew/bin/git
Curl: 7.86.0 => /usr/bin/curl
macOS: 13.2.1-arm64
CLT: N/A
Xcode: 14.2
Rosetta 2: false

What were you trying to do (and why)?

I'm trying to create a (my first) Cask for the Thorium Browser. The Mac releases are shuffled between other "special" releases: https://github.com/Alex313031/Thorium-Special/releases/

This means that the latest version might not always be a MacOS version. At the moment the latest is Westmere Release - M110.0.5481.178 A build only for Westmere CPU's on linux.

I'm now trying to implement a livecheck:

  livecheck do
    url "https://api.github.com/repos/Alex313031/Thorium-Special/releases"
    regex(/.*MacOS.*/i)
    strategy :json do |json, regex|
      json[].select { |item| item["name"]&.match?(regex) }
                      .map { |item| item["tag_name"] }
    end
  end

But it fails with:

$ brew audit --new-cask thorium-chromium
curl: (22) The requested URL returned error: 404
audit for thorium-chromium: failed
 - exception while auditing thorium-chromium: key not found: :latest
Error: 1 problem in 1 cask detected

I guess https://api.github.com/repos/Alex313031/Thorium-Special/releases needs a POST request but brew performs a GET request.

I've very limited knowledge of ruby but when looking at: https://github.com/Homebrew/brew/blob/master/Library/Homebrew/livecheck/strategy/json.rb I would have thought that this should work.

Here is a link to my tap: https://github.com/mietzen/homebrew-thorium-cask

What happened (include all command output)?

$ brew audit --new-cask thorium-chromium
==> Downloading https://formulae.brew.sh/api/formula.jws.json
######################################################################## 100.0%
==> Downloading https://formulae.brew.sh/api/cask.jws.json
######################################################################## 100.0%
curl: (22) The requested URL returned error: 404
audit for thorium-chromium: failed
 - exception while auditing thorium-chromium: key not found: :latest
Error: 1 problem in 1 cask detected

What did you expect to happen?

That the JSON file is loaded.

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

brew tap mietzen/thorium-cask
brew audit --new-cask thorium-chromium
carlocab commented 1 year ago

This looks more like a question than a bug. Please use the discussions page for questions. CC @samford who'll know more about using JSON livecheck.

zetaab commented 1 year ago

@carlocab not sure is this related, but for me it looks like something is broken

% brew update                 
Error: Failed to download https://formulae.brew.sh/api/cask.jws.json!
==> Downloading https://formulae.brew.sh/api/cask.jws.json
curl: (22) The requested URL returned error: 404

Error: Failure while executing; `/usr/bin/env /opt/homebrew/Library/Homebrew/shims/shared/curl --disable --cookie /dev/null --globoff --user-agent Homebrew/4.0.5\ \(Macintosh\;\ arm64\ Mac\ OS\ X\ 13.2.1\)\ curl/7.86.0 --header Accept-Language:\ en --fail --progress-bar --location --remote-time --output /Users/jessehaka/Library/Caches/Homebrew/api/cask.jws.json --compressed --speed-limit 100 --speed-time 5 --progress-bar https://formulae.brew.sh/api/cask.jws.json` exited with 22. Here's the output:
curl: (22) The requested URL returned error: 404
gerdint commented 1 year ago

I have this same issue. I cannot seem to install anything or do a 'brew update'. I'm on MacOS 11.7.4.

Getting https://formulae.brew.sh/api/cask.jws.json simply returns 404.

zetaab commented 1 year ago

seems working again

mietzen commented 1 year ago

This issue was solved by https://github.com/Homebrew/brew/pull/14890 @samford also provided a pull-request in my Repo: https://github.com/mietzen/homebrew-thorium-cask/pull/1

gerdint commented 1 year ago

yup

samford commented 1 year ago

not sure is this related, but for me it looks like something is broken

% brew update                 
Error: Failed to download https://formulae.brew.sh/api/cask.jws.json!
==> Downloading https://formulae.brew.sh/api/cask.jws.json
curl: (22) The requested URL returned error: 404

Error: Failure while executing; `/usr/bin/env /opt/homebrew/Library/Homebrew/shims/shared/curl --disable --cookie /dev/null --globoff --user-agent Homebrew/4.0.5\ \(Macintosh\;\ arm64\ Mac\ OS\ X\ 13.2.1\)\ curl/7.86.0 --header Accept-Language:\ en --fail --progress-bar --location --remote-time --output /Users/jessehaka/Library/Caches/Homebrew/api/cask.jws.json --compressed --speed-limit 100 --speed-time 5 --progress-bar https://formulae.brew.sh/api/cask.jws.json` exited with 22. Here's the output:
curl: (22) The requested URL returned error: 404

Just to clarify, this issue only applies to the brew livecheck command and is unrelated to the formulae.brew.sh API for installing formulae/casks. Any problems with the Homebrew API should be in a separate issue.

terion-name commented 1 year ago

not working again

parkr commented 1 year ago

This was happening intermittently today for me too:

Error: Failed to download https://formulae.brew.sh/api/cask.jws.json!
==> Downloading https://formulae.brew.sh/api/cask.jws.json
  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed
  0  5232    0     0    0     0      0      0 --:--:-- --:--:-- --:--:--     0
curl: (22) The requested URL returned error: 404
Warning: cask.jws.json: update failed, falling back to cached version.

Could we skip a failed formula fetch and just postpone upgrading until it's back?

mietzen commented 1 year ago

@parkr @terion-name You should open a new Issue, your error is not related to this Issue. This issue was specifically about a livecheck that failed from a cask I wrote.

See Samford reply above:

Just to clarify, this issue only applies to the brew livecheck command and is unrelated to the formulae.brew.sh API for installing formulae/casks. Any problems with the Homebrew API should be in a separate issue.

@samford or @carlocab I think it's best if you lock the discussion. Since this Issue is solved.