From e124dddc1601d0f8b6f737d04fc87ece23851ab0 Mon Sep 17 00:00:00 2001 From: Bret Weinraub Date: Sat, 12 Dec 2020 17:27:55 -0700 Subject: [PATCH] RVM now installs itself in system mode to /usr/share/rvm Make this script respect this, and also produce a hopefully helpful error message if rvm goes missing. --- lib/capistrano/tasks/rvm.rake | 66 ++++++++++++++++++++++++++++------- 1 file changed, 53 insertions(+), 13 deletions(-) diff --git a/lib/capistrano/tasks/rvm.rake b/lib/capistrano/tasks/rvm.rake index b2845db..0ceddc0 100644 --- a/lib/capistrano/tasks/rvm.rake +++ b/lib/capistrano/tasks/rvm.rake @@ -1,4 +1,5 @@ -RVM_SYSTEM_PATH = "/usr/local/rvm" +RVM_SYSTEM_PATH = "/usr/share/rvm" +RVM_OLD_SYSTEM_PATH = "/usr/local/rvm" RVM_USER_PATH = "~/.rvm" namespace :rvm do @@ -16,21 +17,60 @@ namespace :rvm do task :hook do on roles(fetch(:rvm_roles, :all)) do rvm_path = fetch(:rvm_custom_path) - rvm_path ||= case fetch(:rvm_type) - when :auto - if test("[ -d #{RVM_USER_PATH} ]") - RVM_USER_PATH - elsif test("[ -d #{RVM_SYSTEM_PATH} ]") - RVM_SYSTEM_PATH - else - RVM_USER_PATH + unless rvm_path + rvm_type = fetch(:rvm_type) + if rvm_type == :auto + [RVM_USER_PATH, + RVM_SYSTEM_PATH, + RVM_OLD_SYSTEM_PATH].each do |pathtotest| + if test("[ -d #{pathtotest} ]") + rvm_path = pathtotest + break + end + end + elsif [:system,:mixed].include?(rvm_type) + rvm_path = RVM_SYSTEM_PATH + else # :user + rvm_path = RVM_USER_PATH end - when :system, :mixed - RVM_SYSTEM_PATH - else # :user - RVM_USER_PATH end + if test("[ ! -d #{rvm_path} ]") + puts <