sportngin / brew-gem

Install gems as homebrew formulas
MIT License
198 stars 22 forks source link

Cannot install mailcatcher gem #50

Closed fschwahn closed 6 years ago

fschwahn commented 6 years ago

This used to work in the past (though I'm not sure with which brew-gem version, but fails now:

➜  ~ brew gem install mailcatcher                
==> Fetching mailcatcher from gem source
Downloaded mailcatcher-0.6.5
Warning: Cannot verify integrity of mailcatcher-0.6.5.gem
A checksum was not provided for this resource
For your reference the SHA256 is: 7d8d5bdac5f86b8801c79ba87add11f44ba661a08a10e14231ae44142c9acf40
==> /usr/bin/gem install /Users/fabian/Library/Caches/Homebrew/mailcatcher-0.6.5
🍺  /usr/local/Cellar/gem-mailcatcher/0.6.5: 1,059 files, 16.3MB, built in 30 seconds
➜  ~ hash -r
➜  ~ mailcatcher
/Library/Ruby/Site/2.3.0/rubygems/dependency.rb:308:in `to_specs': Could not find 'eventmachine' (= 1.0.9.1) among 16 total gem(s) (Gem::MissingSpecError)
Checked in 'GEM_PATH=/Users/fabian/.gem/ruby/2.3.0:/Library/Ruby/Gems/2.3.0:/System/Library/Frameworks/Ruby.framework/Versions/2.3/usr/lib/ruby/gems/2.3.0', execute `gem env` for more information
    from /Library/Ruby/Site/2.3.0/rubygems/dependency.rb:320:in `to_spec'
    from /Library/Ruby/Site/2.3.0/rubygems/core_ext/kernel_gem.rb:65:in `gem'
    from /usr/local/Cellar/gem-mailcatcher/0.6.5/gems/mailcatcher-0.6.5/lib/mail_catcher.rb:3:in `<top (required)>'
    from /Library/Ruby/Site/2.3.0/rubygems/core_ext/kernel_require.rb:133:in `require'
    from /Library/Ruby/Site/2.3.0/rubygems/core_ext/kernel_require.rb:133:in `rescue in require'
    from /Library/Ruby/Site/2.3.0/rubygems/core_ext/kernel_require.rb:40:in `require'
    from /usr/local/Cellar/gem-mailcatcher/0.6.5/gems/mailcatcher-0.6.5/bin/mailcatcher:3:in `<top (required)>'
    from /usr/local/bin/mailcatcher:5:in `load'
    from /usr/local/bin/mailcatcher:5:in `<main>'

I'm on High Sierra, if that makes a difference. Any idea where to start looking?

nicksieger commented 6 years ago

We've had some gems that suddenly don't install on high sierra either and I haven't tracked down the exact cause of the problem. If you want to troubleshoot further, I'd suggest running brew gem formula mailcatcher > mailcatcher.rb and playing around with the resulting formula in mailcatcher.rb. I suspect something to do with the way we are overriding GEM_HOME in the formula may be part of the cause.

fschwahn commented 6 years ago

I was able to fix the issue by replacing the initialization of the gem paths in the generated bin:

I replaced this:

ENV['GEM_HOME']="/usr/local/Cellar/gem-mailcatcher/0.6.5"
ENV['GEM_PATH']="/usr/local/Cellar/gem-mailcatcher/0.6.5"

with this:

Gem.paths = {
  'GEM_HOME' => "/usr/local/Cellar/gem-mailcatcher/0.6.5",
  'GEM_PATH' => "/usr/local/Cellar/gem-mailcatcher/0.6.5"
}

And now it works for me. I found Gem.paths= by googling a bit around (from https://stackoverflow.com/a/30369485/891458), but haven't looked into it further. Maybe it makes sense to use it generally?

nicksieger commented 6 years ago

Ah! I didn't realize that mailcatcher installed but the binstub wasn't working. For that, you might try #49.

fschwahn commented 6 years ago

Ok, just tested it, #49 also fixes the problem. Closing this 👍