Open h0jeZvgoxFepBQ2C opened 10 years ago
:+1:
can patch Capfile like. as it is a Rakefile
task :use_rvm do
require 'capistrano/rvm'
end
task 'staging' => [:use_rvm]
my full Capfile
is:
# Load DSL and Setup Up Stages
require 'capistrano/setup'
# Includes default deployment tasks
require 'capistrano/deploy'
task :use_rvm do
require 'capistrano/rvm'
end
task 'staging' => [:use_rvm]
require 'capistrano/bundler'
require 'capistrano/rails/assets'
require 'capistrano/rails/migrations'
# Loads custom tasks from `lib/capistrano/tasks' if you have any defined.
Dir.glob('lib/capistrano/tasks/*.rake').each { |r| import r }
rake version is 10.1.0
Using the task pattern described before, capistrano/rvm
gets required after capistrano/bundler
. This makes capistrano use the command bundle exec ruby --version
. This command would fail on the server when it is run inside a directory without a Gemfile.
There are two ways to make this work:
1) Avoid using bundle exec
for all ruby commands:
task :require_rvm do
require 'capistrano/rvm'
end
task 'staging' => [:require_rvm]
require 'capistrano/bundler'
set :bundle_bins, %w(gem rake rails)
2) Require bundler the same way we require rvm:
task :require_rvm do
require 'capistrano/rvm'end
task :require_bundler do
require 'capistrano/bundler'
end
task 'staging' => [:require_rvm, :require_bundler]
task 'production' => [:require_bundler]
I have been adding no_hooks to several capistrano gems, so you can load many capistrano plugins on a per-deploy task without any dirty hacks like this one, I'll add a PR soon
Due to historic reasons i use rbenv in production and rvm in staging environment.
The problem is now, that I cannot load capistrano-rvm in the staging.rb cap file:
But if I move the "require 'capistrano/rvm'" it in the Capfile, it also gets loaded in the production environment:
How do I load capistrano-rvm only in staging? Thanks!