Brew: Curl HTTP 416 error when installing cask from URL

Created on 27 Apr 2020  Â·  7Comments  Â·  Source: Homebrew/brew

Please note we will close your issue without comment if you delete, do not read or do not fill out the issue checklist below and provide ALL the requested information. If you repeatedly fail to use the issue template, we will block you from ever submitting issues to Homebrew again.

  • [x] ran brew update and can still reproduce the problem?
  • [x] ran brew doctor, fixed all issues and can still reproduce the problem?
  • [x] ran brew config and brew doctor and included their output with your issue?

What you were trying to do (and why)

I'm trying to install a cask from a formula URL.

The context: I'm developing a meta package manager at https://github.com/kdeldycke/meta-package-manager . For QA I've coded a couple of unittests installing brew packages to reproduce special cases and/or bugs. To stabilize the conditions of my tests, I install snapshotted versions of past formulas. See: https://github.com/kdeldycke/meta-package-manager/blob/develop/meta_package_manager/tests/test_cli_outdated.py#L112-L166

What happened (include command output)

Installing a cask from a formula URL ends up with a 416 HTTP error emitted by curl, while the same command for vanilla brew packages works.


Command output

$ brew cask install https://raw.githubusercontent.com/Homebrew/homebrew-cask/103dde670d398ab32492783a3822132d47f9ebf6/Casks/ubersicht.rb
==> Downloading https://raw.githubusercontent.com/Homebrew/homebrew-cask/103dde670d398ab32492783a3822132d47f9ebf6/Casks/ubersicht.rb.

################################################################## 100.0%

curl: (22) The requested URL returned error: 416
Error: Cask 'ubersicht' is unavailable: Failed to download https://raw.githubusercontent.com/Homebrew/homebrew-cask/103dde670d398ab32492783a3822132d47f9ebf6/Casks/ubersicht.rb. Did you mean “ubersicht”?


What you expected to happen

Here I expect the brew cask install <URL> CLI to work like brew install <URL> CLI and properly handle the 416 HTTP error to have the ubersicht package installed.

Note that is seems this issue has already been fixed in 2017 for brew in #3142, but it doesn't seems it works for casks.

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

Installing a cask from an URL always stumbled upon a 416 HTTP error, whatever the package:

$ brew cask install --verbose https://raw.githubusercontent.com/Homebrew/homebrew-cask/103dde670d398ab32492783a3822132d47f9ebf6/Casks/ubersicht.rb
==> Downloading https://raw.githubusercontent.com/Homebrew/homebrew-cask/103dde670d398ab32492783a3822132d47f9ebf6/Casks/ubersicht.rb.
######################################################################## 100.0%
curl: (22) The requested URL returned error: 416
Error: Cask 'ubersicht' is unavailable: Failed to download https://raw.githubusercontent.com/Homebrew/homebrew-cask/103dde670d398ab32492783a3822132d47f9ebf6/Casks/ubersicht.rb. Did you mean “ubersicht”?
$ brew cask install --verbose https://raw.githubusercontent.com/Homebrew/homebrew-cask/16ea1a95c76beaf2ff4dba161a86721d680756e8/Casks/xld.rb
==> Downloading https://raw.githubusercontent.com/Homebrew/homebrew-cask/16ea1a95c76beaf2ff4dba161a86721d680756e8/Casks/xld.rb.
######################################################################## 100.0%
curl: (22) The requested URL returned error: 416
Error: Cask 'xld' is unavailable: Failed to download https://raw.githubusercontent.com/Homebrew/homebrew-cask/16ea1a95c76beaf2ff4dba161a86721d680756e8/Casks/xld.rb. Did you mean “xld ✔”?
## Output of `brew config` and `brew doctor` commands
$ brew config
HOMEBREW_VERSION: 2.2.13
ORIGIN: https://github.com/Homebrew/brew
HEAD: 3d9cf83fec45a75af61551f53d25383abe009d31
Last commit: 13 days ago
Core tap ORIGIN: https://github.com/Homebrew/homebrew-core
Core tap HEAD: 68fb3b52bb8ce059fc5d1e2fbb6b0dd596b19754
Core tap last commit: 14 minutes ago
HOMEBREW_PREFIX: /usr/local
HOMEBREW_DISPLAY: /private/tmp/com.apple.launchd.81S2cCx6q3/org.macosforge.xquartz:0
HOMEBREW_EDITOR: nvim
HOMEBREW_MAKE_JOBS: 4
HOMEBREW_NO_ANALYTICS: set
CPU: quad-core 64-bit kabylake
Homebrew Ruby: 2.6.3 => /System/Library/Frameworks/Ruby.framework/Versions/2.6/usr/bin/ruby
Clang: 11.0 build 1103
Git: 2.26.2 => /usr/local/bin/git
Curl: 7.64.1 => /usr/bin/curl
Java: 14.0.1
macOS: 10.15.4-x86_64
CLT: 1103.0.32.29
Xcode: N/A
XQuartz: 2.7.11 => /opt/X11

$ brew doctor
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: Putting non-prefixed coreutils in your path can cause gmp builds to fail.

Warning: Putting non-prefixed findutils in your path can cause python builds to fail.

Warning: A .pydistutils.cfg file was found in $HOME, which may cause Python
builds to fail. See:
  https://bugs.python.org/issue6138
  https://bugs.python.org/issue4655

Warning: Unbrewed header files were found in /usr/local/include.
If you didn't put them there on purpose they could cause problems when
building Homebrew formulae, and may need to be deleted.

Unexpected header files:
  /usr/local/include/python2.7/greenlet/greenlet.h

Warning: Broken symlinks were found. Remove them with `brew cleanup`:
  /usr/local/lib/prey/current

All 7 comments

Strange, brew cask fetch works with the url for ubersicht that you quoted:

-bash-5.0.17- /Users/miccal (33) [>  brew cask fetch https://raw.githubusercontent.com/Homebrew/homebrew-cask/103dde670d398ab32492783a3822132d47f9ebf6/Casks/ubersicht.rb
==> Downloading https://raw.githubusercontent.com/Homebrew/homebrew-cask/103dde670d398ab32492783a3822132d47f9ebf6/Casks/ubersicht.rb.
######################################################################## 100.0%

==> Downloading external files for Cask ubersicht
==> Downloading http://tracesof.net/uebersicht/releases/Uebersicht-1.4.61.app.zip
######################################################################## 100.0%
==> Verifying SHA-256 checksum for Cask 'ubersicht'.
==> Success! Downloaded to -> /Users/miccal/Library/Caches/Homebrew/downloads/1f87f1ceb10c4d4ec08c8aeb00da536d77db0bea61ae569d09234d450dacc93a--Uebersicht-1.4.61.app.zip

We do not support issues when installing from URLs. This behaviour is likely to be deprecated in future.

OK, thanks for the feedback! :)

@kdeldycke FWIW most probably you had a cached download at /Users/miccal/Library/Caches/Homebrew/Cask/xld.rb

@MikeMcQuaid FWIW It's sad to hear you might deprecate installing from URLs. Quite a few formulas/casks are often too bleeding-edge (a great thing on its own if you ask me!) and break so then I often just replace a brew install X with brew install https://raw.githubusercontent.com/..../blob/<working-sha>/X.rb until the formula/cask gets fixed.

I hope "installing from URLs" is not the same as "install from local files", and that at the very least brew install <url> can be replaced with wget && brew install.

I often just replace a brew install X with brew install https://raw.githubusercontent.com/..../blob/<working-sha>/X.rb until the formula/cask gets fixed.

We don't support that for a reason. Use brew pin or brew tap-extract instead which are designed for this purpose.

I get the same error when running brew cask audit --download URL, this is currently a step in the PR instructions.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

fxcoudert picture fxcoudert  Â·  3Comments

mislav picture mislav  Â·  3Comments

MikeMcQuaid picture MikeMcQuaid  Â·  3Comments

DomT4 picture DomT4  Â·  3Comments

paanvaannd picture paanvaannd  Â·  4Comments