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

Fix error caused by removal of String#undent #32

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

brandt
Copy link

@brandt brandt commented Jul 8, 2022

Swaps out String#undent for <<~EOF. Also removes the unneeded use of ohai in the caveats section which breaks JSON output.

Background

Homebrew removed their monkeypatch of String#undent in Homebrew/brew#4392 which is causing this error:

$ brew info bnl
blendle/blendle/bnl: stable b2e7a94623b490dcbe5d5c2cb29c68d26433725a, HEAD
Blendle Command-Line Tools
https://github.com/blendle/bnl
Not installed
From: https://github.com/blendle/homebrew-blendle/blob/HEAD/Formula/bnl.rb
==> Options
--HEAD
	Install HEAD version
Error: undefined method `undent' for #<String:0x000000013d8c3c58>
Did you mean?  undef
               indent
               indent!
/opt/homebrew/Library/Taps/blendle/homebrew-blendle/Formula/bnl.rb:19:in `caveats'
/opt/homebrew/Library/Homebrew/caveats.rb:23:in `caveats'
/System/Library/Frameworks/Ruby.framework/Versions/2.6/usr/lib/ruby/2.6.0/forwardable.rb:224:in `empty?'
/opt/homebrew/Library/Homebrew/cmd/info.rb:335:in `info_formula'
/opt/homebrew/Library/Homebrew/cmd/info.rb:153:in `block in print_info'
/opt/homebrew/Library/Homebrew/cmd/info.rb:148:in `each'
/opt/homebrew/Library/Homebrew/cmd/info.rb:148:in `each_with_index'
/opt/homebrew/Library/Homebrew/cmd/info.rb:148:in `print_info'
/opt/homebrew/Library/Homebrew/cmd/info.rb:111:in `info'
/opt/homebrew/Library/Homebrew/brew.rb:93:in `<main>'

Swaps out `String#undent` for `<<~EOF`.

Background
------------

Homebrew removed their monkeypatch of `String#undent` in Homebrew/brew#4392 which is causing this error:

```
$ brew info bnl
blendle/blendle/bnl: stable b2e7a94623b490dcbe5d5c2cb29c68d26433725a, HEAD
Blendle Command-Line Tools
https://github.com/blendle/bnl
Not installed
From: https://github.com/blendle/homebrew-blendle/blob/HEAD/Formula/bnl.rb
==> Options
--HEAD
	Install HEAD version
Error: undefined method `undent' for #<String:0x000000013d8c3c58>
Did you mean?  undef
               indent
               indent!
/opt/homebrew/Library/Taps/blendle/homebrew-blendle/Formula/bnl.rb:19:in `caveats'
/opt/homebrew/Library/Homebrew/caveats.rb:23:in `caveats'
/System/Library/Frameworks/Ruby.framework/Versions/2.6/usr/lib/ruby/2.6.0/forwardable.rb:224:in `empty?'
/opt/homebrew/Library/Homebrew/cmd/info.rb:335:in `info_formula'
/opt/homebrew/Library/Homebrew/cmd/info.rb:153:in `block in print_info'
/opt/homebrew/Library/Homebrew/cmd/info.rb:148:in `each'
/opt/homebrew/Library/Homebrew/cmd/info.rb:148:in `each_with_index'
/opt/homebrew/Library/Homebrew/cmd/info.rb:148:in `print_info'
/opt/homebrew/Library/Homebrew/cmd/info.rb:111:in `info'
/opt/homebrew/Library/Homebrew/brew.rb:93:in `<main>'
```
Calling `ohai` isn’t needed here and is currently breaks JSON output. Example of the issue this change fixes:

```
brew info --all --json
==> For autocompletion try this:

zsh:
source <(bnl completion zsh)

bash, fish:
Nothing yet :-(

[
  {
    "name": "a2ps",
    "full_name": "a2ps",
    "tap": "homebrew/core",
    "oldname": null,
… *snip* -------------------------------->8
```
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

1 participant