Bundle install failing when deploying a Rails 3 app to Dreamhost with Capistrano

心已入冬 提交于 2019-12-19 04:08:16

问题


I am trying to deploy a locally working Rails 3 app to Dreamhost with Capistrano. When I run 'cap deploy -v' in my local app root I get so far before it chokes on 'bundle install'. The following is the end of the error message:

** transaction: start ** [abunchofletters.co.uk :: out] my_username@abunchofletters.co.uk's password: Password: ** [abunchofletters.co.uk :: out] ** [abunchofletters.co.uk :: out] HEAD is now at 62f9cdb Initial deploy to Dreamhost ** [out :: abunchofletters.co.uk] sh: bundle: command not found * [deploy:update_code] rolling back failed: "sh -c 'bundle install --gemfile /home/my_username/abunchofletters.co.uk/releases/20110111100145/Gemfile --path /home/my_username/abunchofletters.co.uk/shared/bundle --deployment --quiet --without development test'" on abunchofletters.co.uk

Yet when I SSH into my server, and check the gem list, bundler 1.0.7 is shown to be installed [also running Ruby 1.8.7, Rails 3.0.3, RubyGems 1.3.6]. This is my first experience with deploying a Rails app as well as Capistrano so I'm close to clueless but I'd guess some path or variable is not set correctly.

Here's my deploy.rb [created from following http://railstips.org/blog/archives/2008/12/14/deploying-rails-on-dreamhost-with-passenger/ so could be outdated]:

require "bundler/capistrano" # http://gembundler.com/deploying.html

default_run_options[:pty] = true

# be sure to change these
set :user,        'my_username'
set :domain,      'abunchofletters.co.uk'
set :application, 'abunchofletters'

# the rest should be good
set :repository,  "#{user}@#{domain}:git/#{application}.git"
set :deploy_to, "/home/#{user}/#{domain}"
set :deploy_via, :remote_cache
set :scm, 'git'
set :branch, 'master'
set :git_shallow_clone, 1
set :scm_verbose, true
set :use_sudo, false

server domain, :app, :web
role :db, domain, :primary => true

namespace :deploy do
  task :restart do
    run "touch #{current_path}/tmp/restart.txt"
  end
end

Any ideas how to progress? If there's any more info you need just prompt me and I'll supply it.


回答1:


I'm not too satisfied with the solution I came up with, but it got the deploy to work and bundler to update.

Here's my updated deploy.rb:

#require "bundler/capistrano"

default_run_options[:pty] = true

# be sure to change these
set :user,        'futureproof'
set :domain,      'abunchofletters.co.uk'
set :application, 'abunchofletters'

# the rest should be good
set :repository,  "#{user}@#{domain}:git/#{application}.git"
set :deploy_to, "/home/#{user}/#{domain}"
set :deploy_via, :remote_cache
set :shared_path, "/home/#{user}/.gems"
set :scm, 'git'
set :branch, 'master'
set :git_shallow_clone, 1
set :scm_verbose, true
set :use_sudo, false

server domain, :app, :web
role :db, domain, :primary => true

namespace :deploy do
  desc "expand the gems"
  task :gems, :roles => :web, :except => { :no_release => true } do
    run "cd #{current_path}; #{shared_path}/bin/bundle unlock"
    run "cd #{current_path}; nice -19 #{shared_path}/bin/bundle install vendor/" # nice -19 is very important otherwise DH will kill the process!
    run "cd #{current_path}; #{shared_path}/bin/bundle lock"
  end

  task :restart do
    run "touch #{current_path}/tmp/restart.txt"
  end
end

The :gems task was seen here: http://grigio.org/deploy_rails_3_passenger_apache_dreamhost, though the bundle lock/unlock are deprecated now. Might be able to simply replace with bundle install/update, but deprecated will do for tonight.



来源:https://stackoverflow.com/questions/4656591/bundle-install-failing-when-deploying-a-rails-3-app-to-dreamhost-with-capistrano

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!