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

Support Linuxbrew #645

Open
BSFishy opened this issue Apr 27, 2021 · 14 comments
Open

Support Linuxbrew #645

BSFishy opened this issue Apr 27, 2021 · 14 comments
Labels
enhancement New feature or request

Comments

@BSFishy
Copy link

BSFishy commented Apr 27, 2021

Problem

I am on a Linux machine right now and I would like to install Stripe CLI through a package manager so that I don't have to deal with updates myself, however it seems that the APT package that I was using is not available anymore. I was looking to use the Homebrew for Linux package instead, however it appears that it only supports Macs. From what I saw, it looks like it shouldn't be too difficult to add support for Linux.

If it is of any use, here is the output I get right now:

~$ brew install stripe/stripe-cli/stripe

==> Tapping stripe/stripe-cli
Cloning into '/home/linuxbrew/.linuxbrew/Homebrew/Library/Taps/stripe/homebrew-stripe-cli'...
remote: Enumerating objects: 288, done.
remote: Counting objects: 100% (120/120), done.
remote: Compressing objects: 100% (80/80), done.
remote: Total 288 (delta 39), reused 0 (delta 0), pack-reused 168
Receiving objects: 100% (288/288), 36.85 KiB | 1.15 MiB/s, done.
Resolving deltas: 100% (94/94), done.
Error: Invalid formula: /home/linuxbrew/.linuxbrew/Homebrew/Library/Taps/stripe/homebrew-stripe-cli/stripe.rb
formulae require at least a URL
Error: Cannot tap stripe/stripe-cli: invalid syntax in tap!

stripe/homebrew-stripe-cli#2

Feature

The addition of a Linux package to the Homebrew formula would allow this package to be installed on Linuxbrew. I'm not sure how this would fit in with your current release process. I did a little bit of digging and can see that Goreleaser is being used and that it sets an install section in the formula. Not entirely sure if it would break if the Linux workflow would break this if it were set there as well.

Examples

N/a. Just being able to install on Linux through Homebrew.

@BSFishy BSFishy added the enhancement New feature or request label Apr 27, 2021
@tomer-stripe
Copy link
Collaborator

Sorry about the trouble here. We lost apt and yum support after the jfrog/bintray deprecation and haven't been able to find a good alternative.

I'm not sure Linuxbrew will be easy for us to do at the moment given our current CI + goreleaser pipeline. Right now we have GitHub actions running and building the CLI on each operating system. The homebrew target only runs on Mac for the Mac builds.

From how I understand goreleaser works, the homebrew recipe is generated based on the previously defined architecture and it completely squashes the prior homebrew recipe everytime we run a new release. So if we added brew to the Linux build it would squash the Mac build.

We could combine some of the build pipelines but I'm worried about platform-specific bugs that could arise here, we've had problems with this in the past and had to add special workarounds to resolve these kinds of issues (see #439). We had to move off of all that though because they weren't keeping up with new Golang releases, which was also introducing problems.

Anyway that's a slightly long winded reply. We'll definitely keep looking into this as we'd really want to make the install process on Linux much easier.

@BSFishy
Copy link
Author

BSFishy commented Apr 27, 2021

I completely understand that viewpoint. If an effort is being put into making it easier to install on Linux, maybe Snap or Flatpak would be an option?

@tomer-stripe
Copy link
Collaborator

I'm not really familiar with either, I'll look into those!

@shivavelingker
Copy link

I am running into a similar issue -- trying to install the CLI via homebrew but cannot due to "invalid syntax in tap." Why is this listed as an option in the documentation if it doesn't work?

@Bandit
Copy link

Bandit commented Jul 22, 2021

Also having this problem. Using Linux because I'm using WSL2 on Windows as my dev machine.

@matheuscandido
Copy link

Also having this problem on Linux. Currently running Ubuntu 21.04.

@bfontaine
Copy link

bfontaine commented Aug 23, 2021

FWIW it’s possible to generate Linux Homebrew formulæ using GoReleaser. I was able to successfully generate a valid Linux formula by simply copy/pasting the brews: section from .goreleaser/mac.yml into .goreleaser/linux.yml:

diff --git .goreleaser/linux.yml .goreleaser/linux.yml
index f7b503e..faf99b8 100644
--- .goreleaser/linux.yml
+++ .goreleaser/linux.yml
@@ -62,3 +62,28 @@ dockers:
       - "--label=org.opencontainers.image.version={{.Version}}"
       - "--label=repository=https://github.com/stripe/stripe-cli"
       - "--label=homepage=https://stripe.com"
+brews:
+  - tap:
+      owner: stripe
+      name: homebrew-stripe-cli
+    commit_author:
+      name: stripe-ci
+      email: [email protected]
+    homepage: https://stripe.com
+    description: Stripe CLI utility
+    install: |
+      bin.install "stripe"
+      rm Dir["#{bin}/{stripe-completion.bash,stripe-completion.zsh}"]
+      system bin/"stripe", "completion", "--shell", "bash"
+      system bin/"stripe", "completion", "--shell", "zsh"
+      bash_completion.install "stripe-completion.bash"
+      zsh_completion.install "stripe-completion.zsh"
+      (zsh_completion/"_stripe").write <<~EOS
+        #compdef stripe
+        _stripe () {
+          local e
+          e=$(dirname ${funcsourcetrace[1]%:*})/stripe-completion.zsh
+          if [[ -f $e ]]; then source $e; fi
+        }
+      EOS
+    caveats: "❤ Thanks for installing the Stripe CLI! If this is your first time using the CLI, be sure to run `stripe login` first."

Then:

# --skip-publish --skip-validate to make it work in local even if v1.7.0 is not the latest commit
goreleaser release -f .goreleaser/linux.yml --skip-publish --skip-validate --rm-dist
# fix the checksum because the generated tarball is not exactly the same as the one published by Stripe
real_checksum=$(curl -Ls https://github.com/stripe/stripe-cli/releases/download/v1.7.0/stripe_1.7.0_linux_x86_64.tar.gz | shasum -a 256 | awk '{print $1}')
sed -i'' 's/sha256 ".*"/sha256 "'$real_checksum'"/' dist/stripe.rb
brew install ./dist/stripe.rb

The code above is just a proof that adding that section in the GoReleaser file work; it shouldn’t be used as-is.

That said, the current workflow runs a goreleaser command per OS, and as such cannot generate a Homebrew formula that works with both Mac and Linux. One workaround would be to publish a Linux-only formula like stripe-linux.rb.

Edit: I wrote this formula: brew install bfontaine/utils/stripe.

@awmcclain
Copy link

Just ran into this as well. It really should be removed from the docs until this is fixed.

@ghenry
Copy link

ghenry commented Mar 16, 2022

FWIW it’s possible to generate Linux Homebrew formulæ using GoReleaser. I was able to successfully generate a valid Linux formula by simply copy/pasting the brews: section from .goreleaser/mac.yml into .goreleaser/linux.yml:

diff --git .goreleaser/linux.yml .goreleaser/linux.yml
index f7b503e..faf99b8 100644
--- .goreleaser/linux.yml
+++ .goreleaser/linux.yml
@@ -62,3 +62,28 @@ dockers:
       - "--label=org.opencontainers.image.version={{.Version}}"
       - "--label=repository=https://github.com/stripe/stripe-cli"
       - "--label=homepage=https://stripe.com"
+brews:
+  - tap:
+      owner: stripe
+      name: homebrew-stripe-cli
+    commit_author:
+      name: stripe-ci
+      email: [email protected]
+    homepage: https://stripe.com
+    description: Stripe CLI utility
+    install: |
+      bin.install "stripe"
+      rm Dir["#{bin}/{stripe-completion.bash,stripe-completion.zsh}"]
+      system bin/"stripe", "completion", "--shell", "bash"
+      system bin/"stripe", "completion", "--shell", "zsh"
+      bash_completion.install "stripe-completion.bash"
+      zsh_completion.install "stripe-completion.zsh"
+      (zsh_completion/"_stripe").write <<~EOS
+        #compdef stripe
+        _stripe () {
+          local e
+          e=$(dirname ${funcsourcetrace[1]%:*})/stripe-completion.zsh
+          if [[ -f $e ]]; then source $e; fi
+        }
+      EOS
+    caveats: "❤ Thanks for installing the Stripe CLI! If this is your first time using the CLI, be sure to run `stripe login` first."

Then:

# --skip-publish --skip-validate to make it work in local even if v1.7.0 is not the latest commit
goreleaser release -f .goreleaser/linux.yml --skip-publish --skip-validate --rm-dist
# fix the checksum because the generated tarball is not exactly the same as the one published by Stripe
real_checksum=$(curl -Ls https://github.com/stripe/stripe-cli/releases/download/v1.7.0/stripe_1.7.0_linux_x86_64.tar.gz | shasum -a 256 | awk '{print $1}')
sed -i'' 's/sha256 ".*"/sha256 "'$real_checksum'"/' dist/stripe.rb
brew install ./dist/stripe.rb

The code above is just a proof that adding that section in the GoReleaser file work; it shouldn’t be used as-is.

That said, the current workflow runs a goreleaser command per OS, and as such cannot generate a Homebrew formula that works with both Mac and Linux. One workaround would be to publish a Linux-only formula like stripe-linux.rb.

Edit: I wrote this formula: brew install bfontaine/utils/stripe.

Have you done a PR for this? It looks simple enough at add Linux support. That's the whole point of Go. There's no way the Homebrew tap should have ever just been for macOS in the first place. That's just silly @tomer-stripe

@bfontaine
Copy link

Have you done a PR for this?

No, because while GoReleaser does support generating a formula for both Linux and macOS, this repo uses different GoReleaser workflows for each platform and I’m not sure how to merge them.

@tomcon
Copy link

tomcon commented Apr 2, 2022

please update your documentation, very poor.
Wasted time installing brew and hit same error on Linux wsl.
Now having to use windows

@unknowncoder05
Copy link

Still same problem, I do use brew for other stuff but still at least a linux no compatibility warning would be appreciated

@BoscoDomingo
Copy link

BoscoDomingo commented Dec 21, 2023

As of December 21st 2023, this is still an ongoing issue. A solution would be greatly appreciated 🙏🏼

Edit: Although not Homebrew, I found asdf (and my favourite alternative, rtx) supports it via a plugin. With it, I can install stripe-cli globally and support versioning as I would with Homebrew

@mhadidg
Copy link

mhadidg commented Aug 28, 2024

This issue remains unresolved, even after over 3 years (1,219 days exactly)

It’s quite disappointing that the maintainers don't seem particularly interested in fixing this 😞

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests