From 8fb3879c5be2f8324dc20caf7281a260e07f5070 Mon Sep 17 00:00:00 2001 From: James Coleman Date: Tue, 17 Jun 2014 11:24:13 -0400 Subject: [PATCH] Handle ruby-build custom definition files gracefully. ruby-build optionally accepts a path to a custom definition file in place of one of the built-in definition names. This patch fixes support for that use case by using the ruby name rather than the path when: * Determining whether an install is needed. * Setting global ruby versions. * Setting file permissions. --- providers/ruby.rb | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/providers/ruby.rb b/providers/ruby.rb index 0de4d28..0fcfeb6 100644 --- a/providers/ruby.rb +++ b/providers/ruby.rb @@ -22,7 +22,9 @@ include Chef::Mixin::Rbenv action :install do - if !new_resource.force && ruby_version_installed?(new_resource.name) + ruby_name = ::File.basename(new_resource.name) + + if !new_resource.force && ruby_version_installed?(ruby_name) Chef::Log.debug "rbenv_ruby[#{new_resource.name}] is already installed so skipping" else Chef::Log.info "rbenv_ruby[#{new_resource.name}] is building, this may take a while..." @@ -45,16 +47,16 @@ } unless Chef::Platform.windows? - shell_out("chmod -R 0775 versions/#{new_resource.name}", chmod_options) - shell_out("find versions/#{new_resource.name} -type d -exec chmod +s {} \\;", chmod_options) + shell_out("chmod -R 0775 versions/#{ruby_name}", chmod_options) + shell_out("find versions/#{ruby_name} -type d -exec chmod +s {} \\;", chmod_options) end new_resource.updated_by_last_action(true) end - if new_resource.global && !rbenv_global_version?(new_resource.name) - Chef::Log.info "Setting #{new_resource.name} as the rbenv global version" - out = rbenv_command("global #{new_resource.name}") + if new_resource.global && !rbenv_global_version?(ruby_name) + Chef::Log.info "Setting #{ruby_name} as the rbenv global version" + out = rbenv_command("global #{ruby_name}") unless out.exitstatus == 0 raise Chef::Exceptions::ShellCommandFailed, "\n" + out.format_for_exception end