From e57b6d11fa39aa96d92a7a6b8c91429974bef81c Mon Sep 17 00:00:00 2001 From: Riccardo Cipolleschi Date: Sun, 26 Feb 2023 09:32:28 -0800 Subject: [PATCH] Remove .ruby-version and update Gemfile to support multiple versions of Ruby (#36281) Summary: This Change remove the need to have a specific version of Ruby installed. We are now supporting a wider range of Ruby versions, starting from Ruby 2.6.10 (the ruby installed on MacOS by default). We are still using a Gemfile to control the version of cocoapods that needs to be installed. ## Changelog [IOS] [CHANGED] - Remove `.ruby-version` and update Gemfile to support a wider range of Ruby versions Pull Request resolved: https://github.com/facebook/react-native/pull/36281 Test Plan: - Tested locally on RNTester and an app from template, switch across different versions of Ruby - CircleCI is green on the commit Reviewed By: cortinico Differential Revision: D43567660 Pulled By: cipolleschi fbshipit-source-id: e7edfe5806a898a83ba39cb58b1318ebde56a57c --- .gitignore | 2 ++ .ruby-version | 1 - Gemfile | 2 +- scripts/update-ruby.sh | 23 ++--------------------- template/Gemfile | 2 +- template/_ruby-version | 1 - 6 files changed, 6 insertions(+), 25 deletions(-) delete mode 100644 .ruby-version delete mode 100644 template/_ruby-version diff --git a/.gitignore b/.gitignore index 4db4e83235ccae..015835188e7b7b 100644 --- a/.gitignore +++ b/.gitignore @@ -105,6 +105,8 @@ package-lock.json # Ruby Gems (Bundler) /vendor /template/vendor +.ruby-version +/**/.ruby-version # iOS / CocoaPods /template/ios/build/ diff --git a/.ruby-version b/.ruby-version deleted file mode 100644 index 49cdd668e1c82b..00000000000000 --- a/.ruby-version +++ /dev/null @@ -1 +0,0 @@ -2.7.6 diff --git a/Gemfile b/Gemfile index 1642cc26ecaa56..cb9f3a332b0b1f 100644 --- a/Gemfile +++ b/Gemfile @@ -1,7 +1,7 @@ source 'https://rubygems.org' # You may use http://rbenv.org/ or https://rvm.io/ to install and use this version -ruby File.read(File.join(__dir__, '.ruby-version')).strip +ruby ">= 2.6.10", "< 3.2.0" gem 'cocoapods', '~> 1.11', '>= 1.11.3' gem 'activesupport', '>= 6.1.7.1' diff --git a/scripts/update-ruby.sh b/scripts/update-ruby.sh index 2e8f39bb74be45..2f0975911925b6 100755 --- a/scripts/update-ruby.sh +++ b/scripts/update-ruby.sh @@ -32,23 +32,6 @@ fi if [ -z "$VERSION" ]; then die "Please provide an installed/usable Ruby version" fi -echo "Setting Ruby version to: $VERSION" - -cd "$ROOT" || die "Failed to change to $ROOT" - -# do this first, so rbenv/rvm will automatically pick the desired version -echo "$VERSION" > .ruby-version - -# make sure we're using it -CURRENT_VERSION=$(ruby --version | cut -d' ' -f2 | cut -dp -f1) -if [ -z "$CURRENT_VERSION" ]; then - # rbenv/rvm uses shims, the commands do exist, but do not return a version if misconfigured - die "Missing usable ruby, check your installation" -elif [ "$VERSION" != "$CURRENT_VERSION" ]; then - die "Plese use the ruby version you are trying to set: $VERSION ('$CURRENT_VERSION' in use)" -fi - -echo "$VERSION" > template/_ruby-version rm -f Gemfile.lock @@ -61,11 +44,9 @@ bundle lock export GIT_DISCOVERY_ACROSS_FILESYSTEM=1; IS_GIT_REPO=$(git rev-parse --is-inside-work-tree 2> /dev/null || true) export GIT_DISCOVERY_ACROSS_FILESYSTEM=0; + if [ "$IS_GIT_REPO" = "true" ]; then - git add \ - .ruby-version \ - Gemfile.lock \ - template/_ruby-version + git add Gemfile.lock else echo "Detected that you're not in Git. If on another SCM, don't forget to commit the edited files." fi diff --git a/template/Gemfile b/template/Gemfile index 567e59805c4a73..89f68756431a30 100644 --- a/template/Gemfile +++ b/template/Gemfile @@ -1,6 +1,6 @@ source 'https://rubygems.org' # You may use http://rbenv.org/ or https://rvm.io/ to install and use this version -ruby File.read(File.join(__dir__, '.ruby-version')).strip +ruby ">= 2.6.10", "< 3.2.0" gem 'cocoapods', '~> 1.11', '>= 1.11.3' diff --git a/template/_ruby-version b/template/_ruby-version deleted file mode 100644 index 49cdd668e1c82b..00000000000000 --- a/template/_ruby-version +++ /dev/null @@ -1 +0,0 @@ -2.7.6