I am using Capistrano to deploy to a VPS. In my deploy.rb
:
require "bundler/capistrano"
server "xxx.xxx.xx.xxx", :web, :app, :db, primary: true
set :application, "riffbox"
set :user, "root"
set :deploy_to, "/home/#{user}/apps/#{application}"
set :deploy_via, :remote_cache
set :use_sudo, false
set :scm, "git"
set :repository, "https://xxxx@bitbucket.org/xxxx/iv.git"
set :branch, "master"
default_run_options[:pty] = true
ssh_options[:forward_agent] = true
after "deploy", "deploy:cleanup" # keep only the last 5 releases
And I got following errors when running cap deploy:cold
:
* 2013-04-13 22:59:38 executing `bundle:install'
* executing "cd /home/root/apps/riffbox/releases/20130413105936 && bundle install --gemfile /home/root/apps/riffbox/releases/20130413105936/Gemfile --path /home/root/apps/riffbox/shared/bundle --deployment --quiet --without development test"
servers: ["198.199.74.146"]
[198.199.74.146] executing command
** [out :: 198.199.74.146] **ERROR: Gem bundler is not installed, run `gem install bundler` first.**
** [out :: 198.199.74.146]
command finished in 915ms
*** [deploy:update_code] rolling back
* executing "rm -rf /home/root/apps/riffbox/releases/20130413105936; true"
servers: ["198.199.74.146"]
[198.199.74.146] executing command
command finished in 907ms
**failed: "sh -c 'cd /home/root/apps/riffbox/releases/20130413105936 && bundle install --gemfile /home/root/apps/riffbox/releases/20130413105936/Gemfile --path /home/root/apps/riffbox/shared/bundle --deployment --quiet --without development test'" on 198.199.74.146**
I can see there are two errors, Bundler
cannot be found and the other one failed to run the sh
command. I followed instruction (https://www.digitalocean.com/community/articles/how-to-install-ruby-on-rails-on-ubuntu-12-04-lts-precise-pangolin-with-rvm) to install rvm, rubygem and rails on my VPS using the root
user.
What else I am missing?
Update
I am using rvm-capistrano, and installed everything using the created user, and got a different error now when deploy:cold:
executing "if [ -d /home/app/riffbox/shared/cached-copy ]; then cd /home/app/riffbox/shared/cached-copy && git fetch -q origin && git fetch --tags -q origin && git reset -q --hard 2afbd8fb661f62a01e0940be38e70915fc3e32ea && git clean -q -d -x -f; else git clone -q git@bitbucket.org:xxx/iv.git /home/app/riffbox/shared/cached-copy && cd /home/app/riffbox/shared/cached-copy && git checkout -q -b deploy 2afbd8fb661f62a01e0940be38e70915fc3e32ea; fi"
servers: ["198.199.74.146"]
Password:
[198.199.74.146] executing command
** [198.199.74.146 :: err] fatal: could not read Password for 'https://xxx@bitbucket.org': No such device or address
Password:
command finished in 7399ms
* [deploy:update_code] rolling back
* executing "rm -rf /home/app/riffbox/releases/20130414224249; true"
servers: ["198.199.74.146"]
[198.199.74.146] executing command
command finished in 586ms
**failed: "rvm_path=$HOME/.rvm/ $HOME/.rvm/bin/rvm-shell '1.9.3@myapp' -c 'if [ -d /home/app/riffbox/shared/cached-copy ]; then cd /home/app/riffbox/shared/cached-copy && git fetch -q origin && git fetch --tags -q origin && git reset -q --hard 2afbd8fb661f62a01e0940be38e70915fc3e32ea && git clean -q -d -x -f; else git clone -q git@bitbucket.org:xxx/iv.git /home/app/riffbox/shared/cached-copy && cd /home/app/riffbox/shared/cached-copy && git checkout -q -b deploy 2afbd8fb661f62a01e0940be38e70915fc3e32ea; fi'" on 198.199.74.146