0

First, I have development app rails on ubuntu using rvm 1.15.8 (stable) by wayne, and I will deploy to my vps.

Here's history of build rails app on my vps :

  1. Install rvm using user "user" on my vps, I tried from this, and here's is rvm info

    [user@myhost ~]$ rvm info
    
    ruby-1.9.3-p392:
    
      system:
        uname:       "Linux mydomain.com 2.6.32-358.6.1.el6.i686 #1 SMP Tue Apr 2
    3 18:13:20 UTC 2013 i686 i686 i386 GNU/Linux"
        system:      "centos/6.4/i386"
        bash:        "/bin/bash => GNU bash, version 4.1.2(1)-release (i386-redhat-l
    inux-gnu)"
        zsh:         " => not installed"
    
      rvm:
        version:      "rvm 1.19.6 (stable) by Wayne E. Seguin <wayneeseguin@gmail.co
    m>, Michal Papis <mpapis@gmail.com> [https://rvm.io/]"
        updated:      "16 hours 9 minutes 44 seconds ago"
    
      ruby:
        interpreter:  "ruby"
        version:      "1.9.3p392"
        date:         "2013-02-22"
        platform:     "i686-linux"
        patchlevel:   "2013-02-22 revision 39386"
        full_version: "ruby 1.9.3p392 (2013-02-22 revision 39386) [i686-linux]"
    
      homes:
        gem:          "/usr/local/rvm/gems/ruby-1.9.3-p392"
        ruby:         "/usr/local/rvm/rubies/ruby-1.9.3-p392"
    
      binaries:
        ruby:         "/usr/local/rvm/rubies/ruby-1.9.3-p392/bin/ruby"
        irb:          "/usr/local/rvm/rubies/ruby-1.9.3-p392/bin/irb"
        gem:          "/usr/local/rvm/rubies/ruby-1.9.3-p392/bin/gem"
        rake:         "/usr/local/rvm/gems/ruby-1.9.3-p392/bin/rake"
    
      environment:
        PATH:         "/usr/local/rvm/gems/ruby-1.9.3-p392/bin:/usr/local/rvm/gems/r
    uby-1.9.3-p392@global/bin:/usr/local/rvm/rubies/ruby-1.9.3-p392/bin:/usr/local/r
    vm/bin:/usr/local/bin:/bin:/usr/bin:/usr/local/sbin:/usr/sbin:/sbin:/home/user/bin"
        GEM_HOME:     "/usr/local/rvm/gems/ruby-1.9.3-p392"
        GEM_PATH:     "/usr/local/rvm/gems/ruby-1.9.3-p392:/usr/local/rvm/gems/ruby-
    1.9.3-p392@global"
        MY_RUBY_HOME: "/usr/local/rvm/rubies/ruby-1.9.3-p392"
        IRBRC:        "/usr/local/rvm/rubies/ruby-1.9.3-p392/.irbrc"
        RUBYOPT:      ""
        gemset:       ""
    
  2. I'm using kloxo control panel for my vps with directory root on /home/admin/myapp/public

  3. I will deploy, and here's deploy.rb

require "bundler/capistrano"
require "rvm/capistrano"

server "xxx.xxx.xxx.xxx", :web, :app, :db, primary: true

set :bundle_cmd, "/usr/local/rvm/gems/ruby-1.9.3-p392@global"
set :bundle_dir, "/usr/local/rvm/gems/ruby-1.9.3-p392"
set :rvm_ruby_string, EVN['GEM_HOME'].gsub(/.*\?/,"")
set :rvm_type, :user

set :default_environment, { 
    'PATH' => "/usr/local/rvm/gems/ruby-1.9.3-p392/bin:/usr/local/rvm/gems/r
uby-1.9.3-p392@global/bin:/usr/local/rvm/rubies/ruby-1.9.3-p392/bin:/usr/local/r
vm/bin:/usr/local/bin:/bin:/usr/bin:/usr/local/sbin:/usr/sbin:/sbin:/home/user/bin",
    'RUBY_VERSION' => 'ruby 1.9.3',
    'GEM_HOME' => "/usr/local/rvm/gems/ruby-1.9.3-p392",
    'GEM_PATH' => "/usr/local/rvm/gems/ruby-1.9.3-p392:/usr/local/rvm/gems/ruby-
1.9.3-p392@global",
    'BUNDLE_PATH' => "/usr/local/rvm/gems/ruby-1.9.3-p392"
}

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

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

default_run_options[:pty] = true
ssh_options[:forward_agent] = true
after "deploy", "deploy:cleanup" # keep only the

I try run cap deploy:setup , I got an error

executing "mkdir -p /home/admin/myapp /home/admin/myapp/release /home/admin/myapp/shared /home/admin/myapp/shared/system /home/admin/myapp/shared/log /home/admin/myapp/shared/pids"
   servers: ["xxx.xxx.xxx.xx"]
Password:
   [xxx.xxx.xxx.xxx] executing command
** [out :: xxx.xxx.xxx.xxx] env : /home/user/.rvm/bin/rvm-shell: No such file or directory
failed : "env PATH: .........etc"

Could you please help me correct my steps and my code ?

rails_id
  • 8,120
  • 4
  • 46
  • 84

2 Answers2

0

Try moving the require for rvm-capistrano to the end of the file. I recently did this as well.

When you are using rvm you don't need to set the bundle cmd, bundle_dir, or default_environment (unless maybe you are doing it for something else?.

It also looks like you are trying to detect the ruby version you are using locally to use in your deployment, to do that set :rvm_ruby_string, :local is all you need

cpuguy83
  • 5,794
  • 4
  • 18
  • 24
  • rvm capistrano will read location of rvm_path `$HOME/.rvm` , while my location of rvm path `/usr/local/rvm/` , so I should to set default rvm_path into `/usr/local/rvm/` . Now, my problem cannot find directory of rmv-shell. – rails_id May 05 '13 at 14:08
  • 2
    Since you are using a system-wide ruby, you need to set the rvm_type to :system – cpuguy83 May 05 '13 at 14:21
  • Thanks @cpuguy83 .. I sould reinstall rvm, because i have used sudo for install rvm, [see](http://stackoverflow.com/a/4945704/1297435).. – rails_id May 05 '13 at 15:18
0

For me,

set :rvm_ruby_string, :local #doesn't work

didn't work. I had to use explicit version:

set :rvm_ruby_string, "2.1.2" #works
  • capistrano (2.15.5)
  • rvm-capistrano (1.5.2)