Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

private homebrew taps reporting uninitialized constant GitHubPrivateRepositoryReleaseDownloadStrategy #967

Closed
wayneashleyberry opened this issue Feb 25, 2019 · 14 comments

Comments

@wayneashleyberry
Copy link
Contributor

wayneashleyberry commented Feb 25, 2019

Describe the bug

The code generated for a homebrew formula does not seem to be working.

The formula is successfully published to a homebrew-tap repo:

# This file was generated by GoReleaser. DO NOT EDIT.
class PrivateRepo < Formula
  desc ""
  homepage "https://github.com/wayneashleyberry/private-repo"
  url "https://github.com/wayneashleyberry/private-repo/releases/download/v2.5.7/private-repo_2.5.7_darwin_amd64.tar.gz", :using => GitHubPrivateRepositoryReleaseDownloadStrategy
  version "2.5.7"
  sha256 "825e071979d2ec25ef9f5dc533556991822816510e2c3abbbbc099fa53f2a3a9"

  def install
    bin.install "foo"
  end

  test do
    system "#{bin}/foo version"
  end
end

I try and tap, but get the following error:

private-repo: uninitialized constant #<Class:0x00007fa86027a348>::GitHubPrivateRepositoryReleaseDownloadStrategy

Full snippet:

bash-5.0$ brew tap wayneashleyberry/homebrew-tap
Updating Homebrew...
==> Tapping wayneashleyberry/tap
Cloning into '/usr/local/Homebrew/Library/Taps/wayneashleyberry/homebrew-tap'...
remote: Enumerating objects: 4, done.
remote: Counting objects: 100% (4/4), done.
remote: Compressing objects: 100% (2/2), done.
remote: Total 4 (delta 0), reused 0 (delta 0), pack-reused 0
Receiving objects: 100% (4/4), done.
Error: Invalid formula: /usr/local/Homebrew/Library/Taps/wayneashleyberry/homebrew-tap/Formula/private-repo.rb
private-repo: uninitialized constant #<Class:0x00007fa86027a348>::GitHubPrivateRepositoryReleaseDownloadStrategy
Error: Cannot tap wayneashleyberry/tap: invalid syntax in tap!
bash-5.0$

To Reproduce

Steps to reproduce the behavior:

# This is an example goreleaser.yaml file with some sane defaults.
# Make sure to check the documentation at http://goreleaser.com
before:
  hooks:
    - rm -fr dist
    - packr2 clean
    - golangci-lint run
    - go test
    - go mod download
    - packr2

builds:
  -
    main: main.go
    binary: foo
    hooks:
      post: packr2 clean

brew:
  github:
    owner: wayneashleyberry
    name: homebrew-tap

  # Allows you to set a custom download strategy.
  download_strategy: GitHubPrivateRepositoryReleaseDownloadStrategy

  # Folder inside the repository to put the formula.
  folder: Formula

  # Your app's homepage.
  homepage: "https://github.com/wayneashleyberry/private-repo"

  # So you can `brew test` your formula.
  test: |
    system "#{bin}/foo version"

Expected behavior

I should be able to brew tap and brew install my binary.

Environment (please complete the following information):

  • OS: macOS
  • OS version: Darwin Your-Mother.local 18.2.0 Darwin Kernel Version 18.2.0: Thu Dec 20 20:46:53 PST 2018; root:xnu-4903.241.1~1/RELEASE_X86_64 x86_64
  • GoReleaser Version [0.101.0, commit none, built at unknown]
  • Homebrew
Homebrew 2.0.2
Homebrew/homebrew-core (git revision da385; last commit 2019-02-25)
Homebrew/homebrew-cask (git revision b01f6; last commit 2019-02-25)
@caarlos0
Copy link
Member

weird, the formula seems correct to me...

@caarlos0
Copy link
Member

  • Darwin Your-Mother.local

😂

@wayneashleyberry
Copy link
Contributor Author

The formula also looks good to me @caarlos0, do you think the issue here is with homebrew?

@caarlos0
Copy link
Member

can be, or maybe they change the strategy name... :/

@wayneashleyberry
Copy link
Contributor Author

wayneashleyberry commented Feb 25, 2019

I can only find one GitHub download strategy in the homebrew source code

https://github.com/Homebrew/brew/blob/master/Library/Homebrew/download_strategy.rb#L796

GitHub
🍺 The missing package manager for macOS (or Linux) - Homebrew/brew

@wayneashleyberry
Copy link
Contributor Author

Changing the strategy name to GitHubGitDownloadStrategy makes the brew tap command work... but I can't actually install the formula.

$ brew install wayneashleyberry/tap/private-repo
==> Installing private-repo from wayneashleyberry/tap
==> Cloning https://github.com/wayneashleyberry/private-repo/releases/download/v2.5.11/private-repo_2.5.11_darwin_amd64.tar.gz
Cloning into '/Users/wayneberry/Library/Caches/Homebrew/private-repo--git'...
fatal: remote error:
  wayneashleyberry/private-repo/releases/download/v2.5.11/private-repo_2.5.11_darwin_amd64.tar.gz is not a valid repository name
  Email support@github.com for help
Error: An exception occurred within a child process:
  DownloadError: Failed to download resource "private-repo"
Failure while executing; `git clone --depth 1 --branch master https://github.com/wayneashleyberry/private-repo/releases/download/v2.5.11/private-repo_2.5.11_darwin_amd64.tar.gz /Users/wayneberry/Library/Caches/Homebrew/private-repo--git` exited with 128. Here's the output:
Cloning into '/Users/wayneberry/Library/Caches/Homebrew/private-repo--git'...
fatal: remote error:
  wayneashleyberry/private-repo/releases/download/v2.5.11/private-repo_2.5.11_darwin_amd64.tar.gz is not a valid repository name
  Email support@github.com for help

@caarlos0
Copy link
Member

yeah, seems like it was removed: Homebrew/brew#5112

@wayneashleyberry
Copy link
Contributor Author

Any idea of how we proceed @caarlos0? Looks that that PR expects the formula / tap to provide the custom download strategy... could goreleaser generate that?

@caarlos0
Copy link
Member

if brew itself don't want to provide that anymore... I don't think goreleaser will

@wayneashleyberry
Copy link
Contributor Author

wayneashleyberry commented Feb 26, 2019

Okay, so I pretty much just copied Library/Homebrew/compat/download_strategy.rb into my private homebrew-tap repo and removed the deprecation notices.

I then set the custom_require config value in my .goreleaser.yml:

brew:
  github:
    owner: foo
    name: homebrew-tap

  # Allows you to set a custom download strategy.
  download_strategy: GitHubPrivateRepositoryReleaseDownloadStrategy

  # Allows you to add a custom require_relative at the top of the formula template
  custom_require: "../custom_download_strategy"

  # Folder inside the repository to put the formula.
  folder: Formula

This is working pretty nicely!

@caarlos0 perhaps we just need to update the docs at https://goreleaser.com/homebrew/ and not necessarily include the download strategies here but point to them somewhere?

@caarlos0
Copy link
Member

caarlos0 commented Mar 3, 2019

it would be awesome, can you make a PR with those changes? Thanks :D

@stale
Copy link

stale bot commented Mar 17, 2019

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

@stale stale bot added the wontfix This will not be worked on label Mar 17, 2019
@stale stale bot closed this as completed Mar 24, 2019
@caarlos0 caarlos0 reopened this Aug 20, 2019
@stale stale bot removed the wontfix This will not be worked on label Aug 20, 2019
@caarlos0
Copy link
Member

Need to document this...

check #1119

@github-actions
Copy link
Contributor

This issue has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Nov 18, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants