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 missing requires for tap-info command #17778

Merged
merged 2 commits into from
Jul 19, 2024

Conversation

kmontag
Copy link
Contributor

@kmontag kmontag commented Jul 16, 2024

Previously, running brew tap-info --installed --json in a github actions linux runner would throw:

Error: uninitialized constant Homebrew::API
/home/linuxbrew/.linuxbrew/Homebrew/Library/Homebrew/tap.rb:1359:in `formula_names'
/home/linuxbrew/.linuxbrew/Homebrew/Library/Homebrew/tap.rb:868:in `to_hash'
/home/linuxbrew/.linuxbrew/Homebrew/Library/Homebrew/cmd/tap-info.rb:87:in `map'
/home/linuxbrew/.linuxbrew/Homebrew/Library/Homebrew/cmd/tap-info.rb:87:in `print_tap_json'
/home/linuxbrew/.linuxbrew/Homebrew/Library/Homebrew/cmd/tap-info.rb:37:in `run'
/home/linuxbrew/.linuxbrew/Homebrew/Library/Homebrew/brew.rb:95:in `<main>'

After the setup steps:

    steps:
      - name: Set up Homebrew
        id: set-up-homebrew
        uses: Homebrew/actions/setup-homebrew@master
        with:
          token: ${{ github.token }}

      - name: Cache Homebrew Bundler RubyGems
        id: cache
        uses: actions/cache@v3
        with:
          path: ${{ steps.set-up-homebrew.outputs.gems-path }}
          key: ${{ runner.os }}-rubygems-${{ steps.set-up-homebrew.outputs.gems-hash }}
          restore-keys: ${{ runner.os }}-rubygems-

      - name: Install Homebrew Bundler RubyGems
        if: steps.cache.outputs.cache-hit != 'true'
        run: brew install-bundler-gems

Previously, running `brew tap-info --installed --json` in a github
actions linux runner would throw:

```
Error: uninitialized constant Homebrew::API
/home/linuxbrew/.linuxbrew/Homebrew/Library/Homebrew/tap.rb:1359:in `formula_names'
/home/linuxbrew/.linuxbrew/Homebrew/Library/Homebrew/tap.rb:868:in `to_hash'
/home/linuxbrew/.linuxbrew/Homebrew/Library/Homebrew/cmd/tap-info.rb:87:in `map'
/home/linuxbrew/.linuxbrew/Homebrew/Library/Homebrew/cmd/tap-info.rb:87:in `print_tap_json'
/home/linuxbrew/.linuxbrew/Homebrew/Library/Homebrew/cmd/tap-info.rb:37:in `run'
/home/linuxbrew/.linuxbrew/Homebrew/Library/Homebrew/brew.rb:95:in `<main>'
```

After the setup steps:
```
    steps:
      - name: Set up Homebrew
        id: set-up-homebrew
        uses: Homebrew/actions/setup-homebrew@master
        with:
          token: ${{ github.token }}

      - name: Cache Homebrew Bundler RubyGems
        id: cache
        uses: actions/cache@v3
        with:
          path: ${{ steps.set-up-homebrew.outputs.gems-path }}
          key: ${{ runner.os }}-rubygems-${{ steps.set-up-homebrew.outputs.gems-hash }}
          restore-keys: ${{ runner.os }}-rubygems-

      - name: Install Homebrew Bundler RubyGems
        if: steps.cache.outputs.cache-hit != 'true'
        run: brew install-bundler-gems
```
@apainintheneck
Copy link
Contributor

I wonder if we want to limit the tap-info command to only loading locally installed taps as if it wasn't using the API. It seems like the original intent of the command is to only show info for locally installed taps.

That would remove the need to add require "api" in this case though it might be needed for some other code paths. This bug is most likely related to this recent PR: #17707

@apainintheneck apainintheneck added the bug Reproducible Homebrew/brew bug label Jul 18, 2024
@apainintheneck
Copy link
Contributor

I'm not able to reproduce these errors on macOS on this branch either. I wonder why it'd behave differently on Linux here.

kmontag added a commit to kmontag/brew-pr-17778-demo that referenced this pull request Jul 18, 2024
kmontag added a commit to kmontag/brew-pr-17778-demo that referenced this pull request Jul 18, 2024
kmontag added a commit to kmontag/brew-pr-17778-demo that referenced this pull request Jul 18, 2024
@kmontag
Copy link
Contributor Author

kmontag commented Jul 18, 2024

Yeah, I'm also not able to reproduce on macOS, or weirdly even with the brew docker image. I only see the error on linux in the github actions context.

Here's a simple demo of the issue: kmontag/brew-pr-17778-demo#1

@kmontag
Copy link
Contributor Author

kmontag commented Jul 18, 2024

And the log from the associated failed run in case it isn't visible:

image

Library/Homebrew/api.rb Outdated Show resolved Hide resolved
Copy link
Contributor

@apainintheneck apainintheneck left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for fixing this!

@apainintheneck apainintheneck merged commit c7342c5 into Homebrew:master Jul 19, 2024
24 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Reproducible Homebrew/brew bug
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants