From c0f4fd99ca2e6d20f32654075e8f80880647ef70 Mon Sep 17 00:00:00 2001 From: Sean Smith Date: Tue, 16 May 2023 11:18:55 -0400 Subject: [PATCH] Allow ruby_build to install new upgrades automatically (#141) Addresses #138 --- CHANGELOG.md | 3 +++ resources/definition.rb | 5 ++++- resources/install.rb | 5 ++++- 3 files changed, 11 insertions(+), 2 deletions(-) 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