简体   繁体   中英

capistrano cap deploy:cold error

Production Server: Ubuntu 12.04, Apache, Passenger, RVM, Ruby 2, Rails 4, Postgresql

I'm getting this error after cap deploy:cold (I changed usernames and IP):

* 2013-03-04 12:17:56 executing `deploy:cold'
  * 2013-03-04 12:17:56 executing `deploy:update'
 ** transaction: start
  * 2013-03-04 12:17:56 executing `deploy:update_code'
    updating the cached checkout on all servers
    executing locally: "git ls-remote git@github.com:user/captest.git master"
    command finished in 4655ms
  * executing "if [ -d /home/user/apps/captest/shared/cached-copy ]; then cd /home/user/apps/captest/shared/cached-copy && git fetch -q origin && git fetch --tags -q origin && git reset -q --hard 0ad1ab0c9e73b41959981a1415f71a42e80c0443 && git clean -q -d -x -f; else git clone -q git@github.com:user/captest.git /home/user/apps/captest/shared/cached-copy && cd /home/user/apps/captest/shared/cached-copy && git checkout -q -b deploy 0ad1ab0c9e73b41959981a1415f71a42e80c0443; fi"
    servers: ["192.33.33.333"]
    [192.33.333.333] executing command
    command finished in 5870ms
    copying the cached version to /home/user/apps/captest/releases/20130304111807
  * executing "cp -RPp /home/user/apps/captest/shared/cached-copy /home/user/apps/captest/releases/20130304111807 && (echo 0ad1ab0c9e73b41959981a1415f71a42e80c0443 > /home/user/apps/captest/releases/20130304111807/REVISION)"
    servers: ["192.33.333.333"]
    [192.33.333.333] executing command
    command finished in 122ms
  * 2013-03-04 12:18:07 executing `deploy:finalize_update'
    triggering before callbacks for `deploy:finalize_update'
  * 2013-03-04 12:18:07 executing `deploy:assets:symlink'
  * executing "rm -rf /home/user/apps/captest/releases/20130304111807/public/assets && mkdir -p /home/user/apps/captest/releases/20130304111807/public && mkdir -p /home/user/apps/captest/shared/assets && ln -s /home/user/apps/captest/shared/assets /home/user/apps/captest/releases/20130304111807/public/assets"
    servers: ["192.33.333.333"]
    ["192.33.333.333"] executing command
    command finished in 134ms
  * 2013-03-04 12:18:07 executing `bundle:install'
  * executing "cd /home/user/apps/captest/releases/20130304111807 && bundle install --gemfile /home/user/apps/captest/releases/20130304111807/Gemfile --path /home/user/apps/captest/shared/bundle --deployment --quiet --without development test"
    servers: ["192.33.333.333"]
    [192.33.333.333] executing command
 ** [out :: 192.33.333.333] sh: 1:
 ** [out :: 192.33.333.333] bundle: not found
 ** [out :: 192.33.333.333] 
    command finished in 110ms
*** [deploy:update_code] rolling back
  * executing "rm -rf /home/user/apps/captest/releases/20130304111807; true"
    servers: ["192.33.333.333"]
    [192.33.333.333] executing command
    command finished in 118ms
failed: "sh -c 'cd /home/user/apps/captest/releases/20130304111807 && bundle install --gemfile /home/user/apps/captest/releases/20130304111807/Gemfile --path /home/user/apps/captest/shared/bundle --deployment --quiet --without development test'" on 192.33.333.333

I basically followed the instructions of the railscasts episode "deploying to vps". This is my deploy.rb file:

require "bundler/capistrano"


server "192.33.333.333", :web, :app, :db, primary: true

set :application, "captest"
set :user, "user"
set :deploy_to, "/home/#{user}/apps/#{application}"
set :deploy_via, :remote_cache
set :use_sudo, false

set :scm, "git"
set :repository, "git@github.com:user/#{application}.git"
set :branch, "master"

default_run_options[:pty] = true
ssh_options[:forward_agent] = true

after "deploy", "deploy:cleanup" # keep only the last 5 releases

namespace :deploy do
  task :start do; end
  task :stop do; end
  task :restart, roles: :app, except: {no_release: true} do
    run "touch #{deploy_to}/current/tmp/restart.txt"
  end

  task :setup_config, roles: :app do
    sudo "ln -nfs #{current_path}/config/apache.conf /etc/apache2/sites-available/#{application}"
    run "mkdir -p #{shared_path}/config"
    put File.read("config/database.example.yml"), "#{shared_path}/config/database.yml"
    puts "Now edit the config files in #{shared_path}."
  end
  after "deploy:setup", "deploy:setup_config"
end

I tried bundle install directly from the server but don't know where because I'm confused of the app structure. Also tried 'require rvm/capistrano' but getting also error.

You still aren't seeing what the real error is.

If -v (for verbose) on the cap deploy:cold command doesn't tell you the real issue then ssh into the server and run the command: cd /home/user/apps/captest/releases/20130304111807 && bundle install --gemfile /home/user/apps/captest/releases/20130304111807/Gemfile --path /home/user/apps/captest/shared/bundle --deployment --quiet --without development test

It sounds like your ruby env may not be setup properly on the server.

EDIT: Actually that may not work if it was deleted. I had a similar issue and I resolved it by manually cloning the project to my production server and running bundle install to debug any issues.

You need to install bundler on the target server.

gem install bundler

It is usually the only gem you need to install in this fashion, because it cannot install itself.

This gist is not exactly suited to your needs, but is how I go about bootstrapping a Ruby 2.0 Ubuntu server, and may help a little: https://gist.github.com/cmaitchison/4083459

I encountered the same issue and determined a solution.

On your server, uninstall all versions of Bundler. You will be prompted to remove the executable. Select yes. Then gem install bundler which should install version 1.3.2 or higher.

In your Gemfile, make sure the source is https , not http . source 'https://rubygems.org'

Cite: https://github.com/carlhuda/bundler/issues/2378#issuecomment-14714639

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM