Skip to content

Commit

Permalink
Remove .ruby-version and update Gemfile to support multiple versions …
Browse files Browse the repository at this point in the history
…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: #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
  • Loading branch information
Riccardo Cipolleschi authored and facebook-github-bot committed Feb 26, 2023
1 parent febf6b7 commit e57b6d1
Show file tree
Hide file tree
Showing 6 changed files with 6 additions and 25 deletions.
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,8 @@ package-lock.json
# Ruby Gems (Bundler)
/vendor
/template/vendor
.ruby-version
/**/.ruby-version

# iOS / CocoaPods
/template/ios/build/
Expand Down
1 change: 0 additions & 1 deletion .ruby-version

This file was deleted.

2 changes: 1 addition & 1 deletion Gemfile
Original file line number Diff line number Diff line change
@@ -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'
23 changes: 2 additions & 21 deletions scripts/update-ruby.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand All @@ -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
2 changes: 1 addition & 1 deletion template/Gemfile
Original file line number Diff line number Diff line change
@@ -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'
1 change: 0 additions & 1 deletion template/_ruby-version

This file was deleted.

0 comments on commit e57b6d1

Please sign in to comment.