Homebrew-core: Using `#{version}` in `url` of Formula

Created on 28 Jun 2016  路  1Comment  路  Source: Homebrew/homebrew-core

In formulas:

  1. Why is url required to be before version?
  2. Should #{version} not be used in url?

In this formula, #{version} is used within the url:

class CloudbreakShell < Formula
  desc "CLI shell for the Cloudbreak project"
  homepage "https://github.com/sequenceiq/cloudbreak/tree/master/shell"
  version "1.4.0-rc.15"
  url "https://s3-eu-west-1.amazonaws.com/maven.sequenceiq.com/releases/com/sequenceiq/cloudbreak-shell/#{version}/cloudbreak-shell-#{version}.jar"

It installs properly, but audit returns:

$ brew audit --online --strict cloudbreak-shell
cloudbreak-shell:
  * `url` (line 5) should be put before `version` (line 4)
Error: 1 problem in 1 formula

If version is moved after url then the url will not include version so receives a 404:

$ brew install cloudbreak-shell
==> Downloading https://s3-eu-west-1.amazonaws.com/maven.sequenceiq.com/releases/com/sequenceiq/cloudbreak-shell//cloudbreak-shell-.jar

curl: (22) The requested URL returned error: 404 Not Found
question

Most helpful comment

We prefer for URLs to be easy to copy and paste, thus to include the verbatim URL. For almost all URLs, version doesn't need to be specified at all because it is automatically detected from the URL.

This translates to this advice:

  • Always use the verbatim URL in a url line.
  • Add a version line after that, if and only if the version isn't automatically detected from the URL.

We realize this is a bit different from most other package managers, but that's the Homebrew way. 馃樃

>All comments

We prefer for URLs to be easy to copy and paste, thus to include the verbatim URL. For almost all URLs, version doesn't need to be specified at all because it is automatically detected from the URL.

This translates to this advice:

  • Always use the verbatim URL in a url line.
  • Add a version line after that, if and only if the version isn't automatically detected from the URL.

We realize this is a bit different from most other package managers, but that's the Homebrew way. 馃樃

Was this page helpful?
0 / 5 - 0 ratings

Related issues

tglawless picture tglawless  路  3Comments

sstadick picture sstadick  路  4Comments

Steffen911 picture Steffen911  路  3Comments

jakepetroules picture jakepetroules  路  3Comments

BluePawDev picture BluePawDev  路  3Comments