Permalink
Browse files

Merge pull request #154 from fnichol/skip-requirements

Call rvm by path for rvm_ruby install/uninstall/remove.
  • Loading branch information...
2 parents dea8328 + 4c3e36a commit 517723d7569472a8afbe8588af7122fc0df5583a @fnichol fnichol committed Jan 25, 2013
Showing with 18 additions and 8 deletions.
  1. +7 −3 libraries/rvm_chef_user_environment.rb
  2. +8 −4 providers/ruby.rb
  3. +3 −1 recipes/default.rb
@@ -21,9 +21,11 @@
def create_rvm_chef_user_environment
klass = Class.new(::RVM::Environment) do
- attr_reader :user
+ attr_reader :user, :source_environment
def initialize(user = nil, environment_name = "default", options = {})
+ @source_environment = options.delete(:source_environment)
+ @source_environment = true if @source_environment.nil?
@user = user
# explicitly set rvm_path if user is set
if @user.nil?
@@ -36,8 +38,10 @@ def initialize(user = nil, environment_name = "default", options = {})
@environment_name = environment_name
@shell_wrapper = ::RVM::Shell::ChefWrapper.new(@user)
@shell_wrapper.setup do |s|
- source_rvm_environment
- use_rvm_environment
+ if source_environment
+ source_rvm_environment
+ use_rvm_environment
+ end
end
end
View
@@ -25,7 +25,11 @@
def load_current_resource
@rubie = normalize_ruby_string(select_ruby(new_resource.ruby_string))
@ruby_string = new_resource.ruby_string
- @rvm_env = ::RVM::ChefUserEnvironment.new(new_resource.user, "default", :rvm_rubygems_version => new_resource.rubygems_version)
+ @rvm_env = ::RVM::ChefUserEnvironment.new(
+ new_resource.user, "default",
+ :rvm_rubygems_version => new_resource.rubygems_version,
+ :source_environment => false
+ )
end
action :install do
@@ -35,7 +39,7 @@ def load_current_resource
Chef::Log.debug("rvm_ruby[#{@rubie}] is already installed, so skipping")
else
install_start = Time.now
- install_options = {}
+ install_options = {:rvm_by_path => true}
install_options[:patch] = new_resource.patch if new_resource.patch
install_ruby_dependencies @rubie
@@ -71,7 +75,7 @@ def load_current_resource
if ruby_installed?(@rubie)
Chef::Log.info("Uninstalling rvm_ruby[#{@rubie}]")
- if @rvm_env.uninstall(@rubie)
+ if @rvm_env.uninstall(@rubie, :rvm_by_path => true)
update_installed_rubies
Chef::Log.debug("Uninstallation of rvm_ruby[#{@rubie}] was successful.")
new_resource.updated_by_last_action(true)
@@ -90,7 +94,7 @@ def load_current_resource
if ruby_installed?(@rubie)
Chef::Log.info("Removing rvm_ruby[#{@rubie}]")
- if @rvm_env.remove(@rubie)
+ if @rvm_env.remove(@rubie, :rvm_by_path => true)
update_installed_rubies
Chef::Log.debug("Removal of rvm_ruby[#{@rubie}] was successful.")
new_resource.updated_by_last_action(true)
View
@@ -18,7 +18,9 @@
#
# install rvm api gem during chef compile phase
-chef_gem 'rvm'
+chef_gem 'rvm' do
+ version '>= 1.11.3.6'
+end
require 'rvm'
create_rvm_shell_chef_wrapper

0 comments on commit 517723d

Please sign in to comment.