Sam Saffron
Sam Saffron

Reputation: 131112

How do I configure capistrano to use my rvm version of Ruby

Does anybody know how I can tell capistrano to use my default rvm version of ruby for on the server I am pushing to. It insists on using the system version.

Is it even possible?

Upvotes: 36

Views: 27424

Answers (6)

Dorian
Dorian

Reputation: 9085

For rbenv, don't forget to change set :rbenv_ruby, "3.0.0" in Capfile :)

Upvotes: 0

muhammadn
muhammadn

Reputation: 330

I found out the easiest way is to add the version you want. Just add

ruby-2.5.0

string (or the version you want) into .ruby-version in the root folder. No need to configure deploy.rb or some rather hacky solutions.

Upvotes: 1

Simone Carletti
Simone Carletti

Reputation: 176402

You have two options:

  1. Enable .ssh environment variables using the PermitUserEnvironment option in your ssh configuration file
  2. Use the capistrano :default_environment setting

For the second option, simply add the following line in your deploy.rb file

set :default_environment, { 
  'PATH' => "/path/to/.rvm/ree-1.8.7-2009.10/bin:/path/to/.rvm/gems/ree/1.8.7/bin:/path/to/.rvm/bin:$PATH",
  'RUBY_VERSION' => 'ruby 1.8.7',
  'GEM_HOME' => '/path/to/.rvm/gems/ree/1.8.7',
  'GEM_PATH' => '/path/to/.rvm/gems/ree/1.8.7' 
}

To get the accurate locations have a look at cat ~/.rvm/default

Upvotes: 37

Matt Scilipoti
Matt Scilipoti

Reputation: 1101

See http://rvm.io/integration/capistrano/. "Integration via the rvm capistrano plugin" looks like a winner.

And http://rvm.io/deployment/

Upvotes: 7

KendallB
KendallB

Reputation: 4807

The rvm-capistrano gem is the best way to go.

Link to the official detailed usage of that gem. From that I am guessing this will get the local version of Ruby:

set :rvm_ruby_string, ENV['GEM_HOME'].gsub(/.*\//,"") # Read from local system

Upvotes: 10

user577149
user577149

Reputation:

If your rvm version is recent on both development and production machines add this to your deploy.rb:

set :rvm_ruby_string, '1.9.2@yourapp' # you probably have this already
set :rvm_type, :user # this is the money config, it defaults to :system

Upvotes: 23

Related Questions