![]() |
VOOZH | about |
There are four choices, listed below from newest to oldest. The first is preferred because it reduces configuration and does not contain hardcoded paths.
:default_environment
setting.
PermitUserEnvironment
option to permit configuration via the
$HOME/.ssh/environment
file. Unfortunately this is not yet documented.
Please refer to the
gem.
Note that in this configuration RVM will not
be automatically loaded as a shell function, although the executable will be available
in the
PATH.
For the differences between the situations, please see
scripting.
RVM >= 1.0.1 includes a built-in plugin (not a gem) for capistrano support. This configuration is nearly identical to the gem approach above, except that an extra line is required to add RVM's lib directory to the load path so that the plugin can be found:
# Choose a Ruby explicitly, or read from an environment variable.
set :rvm_ruby_string, 'ree@rails3'
# set :rvm_ruby_string, ENV['GEM_HOME'].gsub(/.*\//,'')
# Add RVM's lib directory to the load path.
$:.unshift(File.expand_path('./lib', ENV['rvm_path']))
# Load RVM's capistrano plugin.
require 'rvm/capistrano'
Please note, by default the plugin uses a system installation of
RVM, which is the exact opposite of the gem's default installation mode. To
instead set it to use a per-user (non-root) install, add the following to
either your
Capfile
or
deploy.rb
:
set :rvm_type, :user # Literal ":user"
For this option, add the following line in your
deploy.rb
file, adjusting to your particular rvm ruby of course:
set :default_environment, {
'PATH' => "/path/to/.rvm/gems/ree/1.8.7/bin:/path/to/.rvm/bin:/path/to/.rvm/ree-1.8.7-2009.10/bin:$PATH",
'RUBY_VERSION' => 'ruby 1.8.7',
'GEM_HOME' => '/path/to/.rvm/gems/ree-1.8.7-2010.01',
'GEM_PATH' => '/path/to/.rvm/gems/ree-1.8.7-2010.01',
'BUNDLE_PATH' => '/path/to/.rvm/gems/ree-1.8.7-2010.01' # If you are using bundler.
}
To get the accurate locations have a look inside
~/.rvm/config/default
To configure Capistrano to automatically trust project
.rvmrc
files on deployment, add the following to your
config/deploy.rb
:
namespace :rvm do
task :trust_rvmrc do
run "rvm rvmrc trust #{release_path}"
end
end
And then use Capistrano's hooks capabilities, by adding an
after
hook to launch it.
after "deploy", "rvm:trust_rvmrc"