0

I've been looking around a lot for answers to my problem but I can't find a solution that works...so here is my first post ever on stackoverflow!

A while ago I setup an apache server with RVM in order to host one of my client's website. By then, my development environment also had ruby installed through rvm. In the meanwhile, I changed my development environment and now started using VM VirtualBox with Ubuntu, and installed ruby directly from source using apt-get install ruby. I've used Capistrano to deploy all my projects.

Now I've done some work back on that project, but when I tried to deploy it to the production server, I get this error:

2013-07-08 08:12:50 executing `bundle:install'
* executing "cd /var/www/project/releases/20130708061242 && bundle install --gemfile /var/www/project/releases/20130708061242/Gemfile --path /var/www/project/shared/bundle --deployment --quiet --without development test"
    servers: ["xxx.xx.xxx.xxx"]
    [xxx.xx.xxx.xxx] executing command
*** [err :: xxx.xx.xxx.xxx] tput:
*** [err :: xxx.xx.xxx.xxx] No value for $TERM and no -T specified
*** [err :: xxx.xx.xxx.xxx] 
*** [err :: xxx.xx.xxx.xxx] tput:
*** [err :: xxx.xx.xxx.xxx] No value for $TERM and no -T specified
*** [err :: xxx.xx.xxx.xxx] 
 ** [out :: xxx.xx.xxx.xxx] ERROR: Gem bundler is not installed, run `gem install bundler` first.
    command finished in 818ms
*** [deploy:update_code] rolling back
  * executing "rm -rf /var/www/project/releases/20130708061242; true"
    servers: ["xxx.xx.xxx.xxx"]
    [xxx.xx.xxx.xxx] executing command
    command finished in 693ms
failed: "rvm_path=$HOME/.rvm/ $HOME/.rvm/bin/rvm-shell 'default' -c 'cd /var/www/project/releases/20130708061242 && bundle install --gemfile /var/www/project/releases/20130708061242/Gemfile --path /var/www/project/shared/bundle --deployment --quiet --without development test'" on xxx.xx.xxx.xxx

I also have my own testing server and I have no problem when deploying on this one (which has rbenv instead).

Server end stuff is my least knowledgeable area :) Let me know if I can give any additional information that you might need.

Thanks!

EDIT

Here is my deploy.rb

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

server "xxx.xx.xxx.xxx", :app, :web, :db, :primary => true

set :rvm_ruby_string, ENV['GEM_HOME'].gsub(/.*\//,"")
set :rvm_install_ruby_params, '--1.9'      # for jruby/rbx default to 1.9 mode
set :rvm_install_pkgs, %w[libyaml openssl] # package list from https://rvm.io/packages
set :rvm_install_ruby_params, '--with-opt-dir=/usr/local/rvm/usr' # package support

before 'deploy:setup', 'rvm:install_rvm'   # install RVM
before 'deploy:setup', 'rvm:install_pkgs'  # install RVM packages before Ruby
before 'deploy:setup', 'rvm:install_ruby'  # install Ruby and create gemset, or:
before 'deploy:setup', 'rvm:create_gemset' # only create gemset
before 'deploy:setup', 'rvm:import_gemset' # import gemset from file

#General settings
set :ssh_options, { :forward_agent => true }
set :application, "project"
set :repository,  "[email protected]:project.git"
set :deploy_to, "/var/www/#{application}"
set :deploy_via, :remote_cache

set :scm, :git
set :scm_user, "deploy"
set :user, :deploy
set :use_sudo, false
set :keep_releases, 5

after "deploy:update_code", "deploy:migrate"
load "deploy/assets"
9
  • Can you post your deploy.rb file?
    – R Milushev
    Commented Jul 8, 2013 at 6:34
  • Sure, just added it above Commented Jul 8, 2013 at 6:58
  • There is a trouble with your permissions, probably. Take a look at [this discussion]:(github.com/nadarei/mina/issues/5#issuecomment-6995487).
    – R Milushev
    Commented Jul 8, 2013 at 7:08
  • Thing is I don't have rvm anymore in my development environment. Is it fine to install on top of what I currently have? Commented Jul 8, 2013 at 7:12
  • What is the output of ruby -v now ? I would suggest to try to install Ruby from source, it's a good experience.
    – R Milushev
    Commented Jul 8, 2013 at 7:18

1 Answer 1

2

change top part of your deploy.rb to:

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

server "xxx.xx.xxx.xxx", :app, :web, :db, :primary => true

set :rvm_ruby_string, :local

before 'deploy:setup', 'rvm:install_rvm'   # install RVM
before 'deploy:setup', 'rvm:install_ruby'  # install Ruby and create gemset

#General settings
4
  • I get the following error when I try to cap deploy ./config/deploy.rb:14:in load': undefined method gsub' for nil:NilClass (NoMethodError) line 14 being the set :rvm_ruby_string, ENV['GEM_HOME'].gsub(/.*\//,"") line Commented Jul 9, 2013 at 12:31
  • updated the GEM_HOME trick to :local - it would result in an exception Failed to get ruby version from GEM_HOME. Please make sure rvm is loaded! - which means you need locally select a ruby to be able to use it for remote: rvm use ruby, if you do nto use rvm locally then just change it to set :rvm_ruby_string, "1.9.3" - or any other ruby that should be used remotely.
    – mpapis
    Commented Jul 9, 2013 at 16:48
  • Wow! as easy as that! thanks so much mpapis! I wish the documentation for rvm capistrano was a little clearer about that point (details about setting the rvm_ruby_string to :local or and actuall ruby version)..many many thanks! - for those wondering what finally worked: :rvm_ruby_string, "1.9.3" did the trick, as I wasn't using rvm locally anymore Commented Jul 10, 2013 at 6:08
  • the docs are already updated, please open a ticket for the gem if the docs can be improved (make sure to check the latest version before reporting)
    – mpapis
    Commented Jul 10, 2013 at 8:18

Not the answer you're looking for? Browse other questions tagged or ask your own question.