Capistrano: Mismatch gem installation

Found this problem just now. There is a mismatch gem installed between my local machine and deployment server. Here’s what I got from server side:

# rails
/usr/local/rvm/gems/ruby-2.0.0-p247/gems/bundler-1.3.5/lib/bundler/spec_set.rb:92:in `block in materialize': Could not find bcrypt-ruby-3.0.1 in any of the sources (Bundler::GemNotFound)
	from /usr/local/rvm/gems/ruby-2.0.0-p247/gems/bundler-1.3.5/lib/bundler/spec_set.rb:85:in `map!'
	from /usr/local/rvm/gems/ruby-2.0.0-p247/gems/bundler-1.3.5/lib/bundler/spec_set.rb:85:in `materialize'
	from /usr/local/rvm/gems/ruby-2.0.0-p247/gems/bundler-1.3.5/lib/bundler/definition.rb:114:in `specs'
...

I don’t have such problem in my local machine. The server side was deployed using capistrano. I checked the gem installed in server side was version 3.1.2. Of course if this is not deployment server I can do ‘bundle install’ easily, but here’s what I got in server:

# bundle update
You are trying to install in deployment mode after changing
your Gemfile. Run `bundle install` elsewhere and add the
updated Gemfile.lock to version control.

If this is a development machine, remove the Gemfile freeze 
by running `bundle install --no-deployment`.

You have added to the Gemfile:
* source: rubygems repository https://rubygems.org/
* rails (= 4.0.0)
* sqlite3
* sass-rails (~> 4.0.0)
* uglifier (>= 1.3.0)
...

I found it weird at first, “Run `bundle install` elsewhere and add the updated Gemfile.lock to version control.”. But later I realized it is easy to fix, just go outside application folder and go to another application or simply create new rails apps, then open Gemfile and set the required gem. Below is the sample:

...
gem 'bcrypt-ruby', '~> 3.0.0'
...

Saved it, and run ‘bundle install’. This way, server will be updated with required gem (old version) and remove the latest one. So when we get back to application folder deployed by capistrano it will run normally.

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s