Capistrano cannot find gem in production

633 views Asked by At

Hi I think I am missing something basic here.

I am using Capistrano to deploy to 'integration' and then to 'testing'.

I cannot seem to add a gem and then deploy successfully with Capistrano to one of the websites ('testing'). However I can deploy it successfully to the other one('integration').

I am trying to add bootstrap-sass '~> 3.0.2.0', but the same error occurs with other gems when I try to add them.

When I attempt to deploy to 'testing' with 'cap testing deploy' I get an error which reads

whenever --update-crontab registration --set environment=testing --roles db"
    servers: ["test.calm.dhamma.org"]
    [test.calm.dhamma.org] executing command
*** [err :: test.calm.dhamma.org] /home/calm/.rvm/gems/ruby-1.9.3-p448/gems/bundler-1.3.5/lib/bundler/spec_set.rb:92:in `block in materialize'
*** [err :: test.calm.dhamma.org] :
*** [err :: test.calm.dhamma.org] Could not find bootstrap-sass-3.0.3.0 in any of the sources
*** [err :: test.calm.dhamma.org] (
*** [err :: test.calm.dhamma.org] Bundler::GemNotFound
*** [err :: test.calm.dhamma.org] )
*** [err :: test.calm.dhamma.org] from /home/calm/.rvm/gems/ruby-1.9.3-p448/gems/bundler-1.3.5/lib/bundler/spec_set.rb:85:in `map!'
*** [err :: test.calm.dhamma.org] from /home/calm/.rvm/gems/ruby-1.9.3-p448/gems/bundler-1.3.5/lib/bundler/spec_set.rb:85:in `materialize'
*** [err :: test.calm.dhamma.org] from /home/calm/.rvm/gems/ruby-1.9.3-p448/gems/bundler-1.3.5/lib/bundler/definition.rb:114:in `specs'
*** [err :: test.calm.dhamma.org] from /home/calm/.rvm/gems/ruby-1.9.3-p448/gems/bundler-1.3.5/lib/bundler/definition.rb:159:in `specs_for'
*** [err :: test.calm.dhamma.org] from /home/calm/.rvm/gems/ruby-1.9.3-p448/gems/bundler-1.3.5/lib/bundler/definition.rb:148:in `requested_specs'
etc..

I have spent a long time looking for answers with no success. I do have

require 'bundler/capistrano'

in my Capfile.rb as you can see below.

require "rvm/capistrano"

#set :rvm_type, :system    # :user is the default

set :rvm_ruby_string, ENV['GEM_HOME'].gsub(/.*\//,"") # Read from local system
puts "RVM ruby string = "
puts rvm_ruby_string
#set :rvm_ruby_string, :local
#
set :rvm_autolibs_flag, "read-only"

before 'deploy:setup', 'rvm:install_rvm' 
before 'deploy:setup', 'rvm:install_ruby'


require 'bundler/capistrano'

require 'capistrano/ext/multistage'
set :stages, ["integration","testing", "production"]
set :default_stage, "integration"

# use whenever gem. Only if you have chron jobs
require "whenever/capistrano"
set :whenever_command, "bundle exec whenever"

set :application, "registration"
set :repository,  "ssh://[email protected]/home/gitrepo/repositories/registration"
#set :repository,  "ssh://[email protected]/home/gitrepo/repositories/registration"

set :scm, :git
# Or: `accurev`, `bzr`, `cvs`, `darcs`, `git`, `mercurial`, `perforce`, `subversion` or `none`


set :deploy_to,       "/home/calm/wwwshare/registration"
set :user,            "calm"
set :use_sudo,        false
set :ssh_options,     { :forward_agent => true }

#set :deploy_to, "/home/calm/wwwshare/#{application}"
set :deploy_via, :remote_cache

#before "deploy:bundle_gems","deploy:symlink_vendor"
#after "deploy", "deploy:bundle_gems"
#after "deploy:bundle_gems", "assets:symlink"
#after "assets:symlink", "deploy:copy_database_configuration"
#after "deploy:copy_database_configuration", "deploy:restart"

# http://beginrescueend.com/integration/capistrano/

#set :default_environment, {
#    'PATH' => "/home/calm/.rvm/gems/ruby-1.9.3-p448/bin:/home/calm/.rvm/gems/ruby-1.9.3-p448@global/bin:/home/calm/.rvm/bin:/home/calm/.rvm/rubies/ruby-1.9.3-p448/bin:$PATH",
#    'RUBY_VERSION' => 'ruby-1.9.3-p448',
#    'GEM_HOME'     => '/home/calm/.rvm/gems/ruby-1.9.3-p448',
#    'GEM_PATH'     => '/home/calm/.rvm/gems/ruby-1.9.3-p448:/home/calm/.rvm/gems/ruby-1.9.3-p448@global',
#    'BUNDLE_PATH'  => '/home/calm/.rvm/gems/ruby-1.9.3-p448'  # If you are using bundler.
#}

#task :testing do
#  server 'THE-SERVER.mudbugmedia.com', :web, :app, :db, :primary => true
#  set :deploy_to, '/home/calm/wwwshare/#{application}'
#  set :rails_env, 'testing'
#  set :branch,    'master'
#end

after 'deploy:setup', :create_configs
desc 'Create the shared/config dir for various config files'
task :create_configs do
  run "mkdir -p #{shared_path}/config"
  run "touch #{shared_path}/config/database.yml"
end

after 'deploy:finalize_update', :update_configs
desc 'Copy the shared config files to the release config dir'
task :update_configs do
  run "cp -Rf #{shared_path}/config/* #{release_path}/config"
end

#after 'deploy:finalize_update', :bundle_gems
#desc "Install gems ??? or  require 'bundler/capistrano'"
#task :bundle_gems do
#  run "cd #{release_path} && bundle install --path vendor/gems"
#end


# If you are using Passenger
 namespace :deploy do
   task :start do ; end
   task :stop do ; end
   task :restart, :roles => :app, :except => { :no_release => true } do
     run "#{try_sudo} touch #{File.join(current_path,'tmp','restart.txt')}"
   end
 end

I have tried installing the gem directly in the 'testing' website by editing the Gemfile and Gemfile.lock there to be consistent with the ones on my development and the 'integration' site and running bundle install.

Then when I 'bundle show' I get

bundle show bootstrap-sass
....../.rvm/gems/ruby-1.9.3-p448/gems/bootstrap-sass-3.0.2.1

and then:

bundle exec gem list
Could not find bootstrap-sass-3.0.2.1 in any of the sources
Run `bundle install` to install missing gems.

cap testing deploy still fails as well

On the site which works the gem is installed as shown below:

bundle show bootstrap-sass
...../registration/shared/bundle/ruby/1.9.1/gems/bootstrap-sass-3.0.2.1

which is different from where I installed it manually on the site that does not work.

So, my questions are:

Why does Capistrano fail to add new gems to one site but succeed with the other?

Should I install the gem directly on the site that doesn't work as I tried? And if that is a good idea, how would I get it to install into the right place?

Ryan

1

There are 1 answers

0
ryan2johnson9 On BEST ANSWER

Now making my comment an answer:

It is working now - it seems there was an issue with differing ruby versions. I had 1.9.7 p448 on my local and test had 1.9.7 p484. We just set all our versions on each machine to the same one and I can now use Capistrano to update the gems based on changes to the Gemfile.