MikeKusold
MikeKusold

Reputation: 1632

Allow bundler to continue if gem fails and isn't required

My goal is to have bundler try to install each gem, but if a gem fails to install (normally due to native extensions), AND the gem isn't required then it proceeds to try to install the next.

I've been struggling with this for a while, and it is due to trying to build rb-fsevent with native extensions for growl_notify on linux. Any help would be appreciated.

Gemfile:

source 'http://rubygems.org'

def darwin_only(require_as)
  RUBY_PLATFORM.include?('darwin') && require_as
end

def linux_only(require_as)
  RUBY_PLATFORM.include?('linux') && require_as
end

gem 'sinatra'
gem 'httparty', '~>0.8.1'

group :development do
  gem 'shotgun'
  gem 'heroku'

  gem 'jasmine-headless-webkit'
  gem 'guard-jasmine-headless-webkit'
  gem 'growl_notify', require: darwin_only('growl_notify')
  gem 'rb-fsevent',   require: darwin_only('rb-fsevent') 
  gem 'rb-inotify',   require: linux_only('rb-inotify')
  gem 'libnotify',    require: linux_only('libnotify')
end

Upvotes: 2

Views: 76

Answers (1)

Daiku
Daiku

Reputation: 1227

I've struggled with this also. I've resorted to creating another group, and putting those that fail into that group, then gem install --without group. There are ways to modify the gem install behavior based on platform if it's your own gem, but if you're not controlling the code, then this the only thing I was able to come up with. Hopefully, the platforms you are dealing with correspond to your groups for development, production, etc.

I think this is really your issue: Make bundler use different gems for different platforms

Upvotes: 2

Related Questions