diff --git a/CHANGELOG.md b/CHANGELOG.md index 1dd89ab..1c19d06 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -7,6 +7,9 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ## Unreleased +- Allow ruby-build to recognize when it needs to be upgraded. +- Allow ruby-build to reinstall Ruby if the version changes. + ## 2.4.1 - *2023-05-16* ## 2.4.0 - *2023-05-16* diff --git a/resources/definition.rb b/resources/definition.rb index 637fd68..763cc3d 100644 --- a/resources/definition.rb +++ b/resources/definition.rb @@ -87,7 +87,10 @@ environment env user new_resource.user group new_resource.group - not_if { ::File.exist?("#{installation_path}/bin") } + not_if do + ::Dir.exist?("#{installation_path}/bin") && + new_resource.definition == `#{installation_path}/bin/ruby -e 'print RUBY_VERSION'` + end live_stream true action :run end diff --git a/resources/install.rb b/resources/install.rb index 4b0d1bc..d3c8daf 100644 --- a/resources/install.rb +++ b/resources/install.rb @@ -33,6 +33,9 @@ execute 'Install ruby-build' do cwd src_path command %(sh ./install.sh) - not_if { ::File.exist?('/usr/local/bin/ruby-build') } + not_if do + ::File.exist?('/usr/local/bin/ruby-build') && + `#{src_path}/bin/ruby-build --version` == `/usr/local/bin/ruby-build --version` + end end end