Homebrew / homebrew-bundle

📦 Bundler for non-Ruby dependencies from Homebrew, Homebrew Cask and the Mac App Store.
MIT License
5.29k stars 284 forks source link

brew bundle dump spawns many ruby processes #1351

Closed k-obrien closed 4 months ago

k-obrien commented 4 months ago
HOMEBREW_VERSION: 4.2.20
ORIGIN: https://github.com/Homebrew/brew
HEAD: c2ed3327c605c3e738359c9807b8f4cd6fec09eb
Last commit: 26 hours ago
Core tap JSON: 30 Apr 04:46 UTC
Core cask tap JSON: 30 Apr 04:52 UTC
HOMEBREW_PREFIX: /opt/homebrew
HOMEBREW_CASK_OPTS: []
HOMEBREW_EDITOR: codium --wait
HOMEBREW_MAKE_JOBS: 14
HOMEBREW_NO_ANALYTICS: set
Homebrew Ruby: 3.1.4 => /opt/homebrew/Library/Homebrew/vendor/portable-ruby/3.1.4/bin/ruby
CPU: 14-core 64-bit arm_palma
Clang: 15.0.0 build 1500
Git: 2.45.0 => /opt/homebrew/bin/git
Curl: 8.4.0 => /usr/bin/curl
macOS: 14.4.1-arm64
CLT: 15.3.0.0.1.1708646388
Xcode: N/A
Rosetta 2: false

Recently, when running brew bundle dump, the process does not complete and spawns ruby processes until memory is exhausted.

Running pkill ruby from another terminal results in the following output beginning at Error: SIGTERM:

❯ brew bundle dump
==> Downloading https://formulae.brew.sh/api/formula.jws.json
##O=#    #
Error: SIGTERM
/opt/homebrew/Library/Homebrew/utils/popen.rb:49:in `read'
/opt/homebrew/Library/Homebrew/utils/popen.rb:49:in `block in popen'
/opt/homebrew/Library/Homebrew/utils/popen.rb:47:in `popen'
/opt/homebrew/Library/Homebrew/utils/popen.rb:47:in `popen'
/opt/homebrew/Library/Homebrew/utils/popen.rb:9:in `popen_read'
/opt/homebrew/Library/Homebrew/utils/popen.rb:16:in `safe_popen_read'
/opt/homebrew/Library/Taps/homebrew/homebrew-bundle/lib/bundle/brew_services.rb:41:in `started_services'
/opt/homebrew/Library/Taps/homebrew/homebrew-bundle/lib/bundle/brew_services.rb:35:in `started?'
/opt/homebrew/Library/Taps/homebrew/homebrew-bundle/lib/bundle/brew_dumper.rb:68:in `block in dump'
/opt/homebrew/Library/Taps/homebrew/homebrew-bundle/lib/bundle/brew_dumper.rb:58:in `map'
/opt/homebrew/Library/Taps/homebrew/homebrew-bundle/lib/bundle/brew_dumper.rb:58:in `dump'
/opt/homebrew/Library/Taps/homebrew/homebrew-bundle/lib/bundle/dumper.rb:22:in `build_brewfile'
/opt/homebrew/Library/Taps/homebrew/homebrew-bundle/lib/bundle/dumper.rb:35:in `dump_brewfile'
/opt/homebrew/Library/Taps/homebrew/homebrew-bundle/lib/bundle/commands/dump.rb:11:in `run'
/opt/homebrew/Library/Taps/homebrew/homebrew-bundle/cmd/bundle.rb:135:in `run'
/opt/homebrew/Library/Homebrew/brew.rb:92:in `<main>'
If reporting this issue please do so at (not Homebrew/brew or Homebrew/homebrew-core):
  https://github.com/homebrew/homebrew-bundle/issues/new
jacobbednarz commented 4 months ago

can you provide more details here? using my existing setup (~ 150 entries) i can't replicate this.

MikeMcQuaid commented 4 months ago

To help us debug this issue can you explain:

Closing until we have this.

k-obrien commented 4 months ago

What you were trying to do (and why)

Dump my installed packages to a brewfile.

What happened

The command hung after outputting the following:

❯ brew bundle dump
==> Downloading https://formulae.brew.sh/api/formula.jws.json
##O=#    #

What you expected to happen

I expected my installed packages to be written to ./Brewfile

Step-by-step reproduction instructions (with as minimal input data as possible)

  1. Run brew bundle dump
  2. Wait a few seconds
  3. Open Activity Monitor and see ruby processes replicating
  4. Open a new terminal prompt and run pkill ruby
  5. Switch back to original prompt and see below output:
    Error: SIGTERM
    /opt/homebrew/Library/Homebrew/utils/popen.rb:49:in `read'
    /opt/homebrew/Library/Homebrew/utils/popen.rb:49:in `block in popen'
    /opt/homebrew/Library/Homebrew/utils/popen.rb:47:in `popen'
    /opt/homebrew/Library/Homebrew/utils/popen.rb:47:in `popen'
    /opt/homebrew/Library/Homebrew/utils/popen.rb:9:in `popen_read'
    /opt/homebrew/Library/Homebrew/utils/popen.rb:16:in `safe_popen_read'
    /opt/homebrew/Library/Taps/homebrew/homebrew-bundle/lib/bundle/brew_services.rb:41:in `started_services'
    /opt/homebrew/Library/Taps/homebrew/homebrew-bundle/lib/bundle/brew_services.rb:35:in `started?'
    /opt/homebrew/Library/Taps/homebrew/homebrew-bundle/lib/bundle/brew_dumper.rb:68:in `block in dump'
    /opt/homebrew/Library/Taps/homebrew/homebrew-bundle/lib/bundle/brew_dumper.rb:58:in `map'
    /opt/homebrew/Library/Taps/homebrew/homebrew-bundle/lib/bundle/brew_dumper.rb:58:in `dump'
    /opt/homebrew/Library/Taps/homebrew/homebrew-bundle/lib/bundle/dumper.rb:22:in `build_brewfile'
    /opt/homebrew/Library/Taps/homebrew/homebrew-bundle/lib/bundle/dumper.rb:35:in `dump_brewfile'
    /opt/homebrew/Library/Taps/homebrew/homebrew-bundle/lib/bundle/commands/dump.rb:11:in `run'
    /opt/homebrew/Library/Taps/homebrew/homebrew-bundle/cmd/bundle.rb:135:in `run'
    /opt/homebrew/Library/Homebrew/brew.rb:92:in `<main>'
    If reporting this issue please do so at (not Homebrew/brew or Homebrew/homebrew-core):
    https://github.com/homebrew/homebrew-bundle/issues/new

brew bundle --help, for example, completes fine. I haven't tried other subcommands.

Please let me know if you need anything else. Thanks!

MikeMcQuaid commented 4 months ago

@k-obrien I'm afraid this isn't reproducible.

What does brew config, brew doctor and brew services list output?

k-obrien commented 4 months ago
❯ brew config
HOMEBREW_VERSION: 4.2.20
ORIGIN: https://github.com/Homebrew/brew
HEAD: c2ed3327c605c3e738359c9807b8f4cd6fec09eb
Last commit: 30 hours ago
Core tap JSON: 30 Apr 09:06 UTC
Core cask tap JSON: 30 Apr 04:52 UTC
HOMEBREW_PREFIX: /opt/homebrew
HOMEBREW_CASK_OPTS: []
HOMEBREW_EDITOR: codium --wait
HOMEBREW_MAKE_JOBS: 14
HOMEBREW_NO_ANALYTICS: set
Homebrew Ruby: 3.1.4 => /opt/homebrew/Library/Homebrew/vendor/portable-ruby/3.1.4/bin/ruby
CPU: 14-core 64-bit arm_palma
Clang: 15.0.0 build 1500
Git: 2.45.0 => /opt/homebrew/bin/git
Curl: 8.4.0 => /usr/bin/curl
macOS: 14.4.1-arm64
CLT: 15.3.0.0.1.1708646388
Xcode: N/A
Rosetta 2: false
❯ brew doctor
Your system is ready to brew.
❯ brew services list
Name    Status User File
unbound none
MikeMcQuaid commented 4 months ago
/opt/homebrew/Library/Taps/homebrew/homebrew-bundle/lib/bundle/brew_services.rb:41:in `started_services'

If it's failing here: it's just running brew services list so I'm afraid I have no idea what's going on here, sorry 😭

k-obrien commented 4 months ago

Very strange. This is consistently reproducible 100% of the time for me. Stranger still is that this is happening on a brand new machine with a completely new environment, but it was also happening on my old machine. 🤔

In any case, it's more an annoyance than anything else so I guess we can close this issue and I'll just manually update my brewfile. Thanks for the prompt help though.

MikeMcQuaid commented 4 months ago

@k-obrien Sounds like it may be a configuration issue. Might be worth checking your dotfiles etc.?

k-obrien commented 4 months ago

That seems plausible as almost the first thing I did on this new machine was to clone and deploy my dotfiles repo. Any ideas what I might be looking for @MikeMcQuaid? I can't think of anything that would affect ruby or file processes...

I don't expect you to look at my dotfiles and help me diagnose those BTW. Just thought you might scan the list of items and see if anything leaped out at you as something I should look at. 😅

MikeMcQuaid commented 4 months ago

@k-obrien no idea, I'm afraid! Could try commenting out your shell environment variables or creating a new shell with variables/functions/aliases unset and see what causes the issue? Sorry I can't be more help 😭

k-obrien commented 4 months ago

Thanks for putting me on the right track @MikeMcQuaid. The command works as expected in zsh (for which I have almost zero configuration in place), so that gives me both a workaround and a starting point for investigation. I'll update here if/when I find out the cause under fish. Thanks again for your help!

k-obrien commented 4 months ago

... And now it inexplicably works under fish again, with no changes to my configuration. 🤦🏻