Because of the nth time installing rbenv manually I wrote the following lines, which adds cap #{env} rbenv:install to the list of available tasks. It may relate to this request (never tried the 2.x version): https://github.com/capistrano/rbenv/issues/51
namespace :rbenv do
desc 'Install rbenv'
task :install do
on roles(:web) do
begin
execute "git clone https://github.com/rbenv/rbenv.git #{fetch(:rbenv_path)}"
rescue SSHKit::Command::Failed
puts "rbenv already installed, updating..."
execute "cd #{fetch(:rbenv_path)} && git pull"
end
# execute "~/.rbenv/bin/rbenv init"
execute "mkdir -p #{fetch(:rbenv_path)}/plugins"
begin
execute "git clone https://github.com/rbenv/ruby-build.git #{fetch(:rbenv_path)}/plugins/ruby-build"
rescue SSHKit::Command::Failed
puts "rbenv/ruby-build plugin already installed, updating..."
execute "cd #{fetch(:rbenv_path)}/plugins/ruby-build && git pull"
end
rbenv_ruby = File.read('.ruby-version').strip
execute "#{fetch(:rbenv_path)}/bin/rbenv install -s #{fetch(:rbenv_ruby)||rbenv_ruby}"
execute "#{fetch(:rbenv_path)}/bin/rbenv global #{fetch(:rbenv_ruby)||rbenv_ruby}"
execute "#{fetch(:rbenv_path)}/shims/gem install bundler --no-document"
if fetch(:rbenv_ruby).nil?
puts "\nPlease uncomment the line `# set :rbenv_ruby, File.read('.ruby-version').strip` to enable capistrano rbenv"
end
end
end
end
Because of the nth time installing rbenv manually I wrote the following lines, which adds cap #{env} rbenv:install to the list of available tasks. It may relate to this request (never tried the 2.x version): https://github.com/capistrano/rbenv/issues/51
I'm happy to prepare a pull request...