Search code examples
ruby-on-railslinuxmacosbundlerguard

Bundler error on deployment


I'm currently using guard i.e. guard-coffeescript gem to compile my javascript (and in the future I'll probably add some more guard tasks) on my OSX dev system. I added the rb-fsevent gem to my Gemspec, now I saw that in a lot of Gemspecs it is added with an if statement like this:

gem 'rb-fsevent', :require => false if RUBY_PLATFORM =~ /darwin/i

Trying to deploy to my staging/production environment, which is running under Linux, the script executed on the server uses the bundle install --deployment results in following exception:

# bundle install --deployment
You have modified your Gemfile in development but did not check
the resulting snapshot (Gemfile.lock) into version control

You have deleted from the Gemfile:
* rb-fsevent

Is there a way around this problem or do I just have to remove the if so that I can deploy to my system and in turn installing a gem that is useless on a non OSX platform?

--

edit: I run bundle install before deploying to my staging environment and run bundle check after the first time it failed. I got it running after removing the if statement..


Solution

  • I had a similar problem. If you're using capistrano you can set the following option:

    set :bundle_without, [:darwin, :development, :test]
    

    Then wrap your gem 'rb-fsevent' line in a group called darwin. Something like this should work nicely:

    group :test, :darwin do
      gem 'rb-fsevent'
    end
    

    This makes bundler do this on the server:

    bundle --without darwin development test
    

    Which means that it ignores those groups in the Gemfile.lock. What you were doing would make you OS X machine and your server come up with different resulting lock files. Which is why it was complaining.