Skip to content

Commit

Permalink
Actually install the correct version of ruby to install cocoapods
Browse files Browse the repository at this point in the history
- If we already have the desired version, we are good
- If we don't, but we have brew, we install the desired version
- If we don't have brew, but we have a sufficiently recent OSX, we are good
- If we don't have brew and we don't have a sufficiently recent OSX, we warn that there might be problems
  • Loading branch information
shankari committed Feb 11, 2023
1 parent c67cdc6 commit 2126a73
Show file tree
Hide file tree
Showing 3 changed files with 38 additions and 21 deletions.
4 changes: 4 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -120,6 +120,10 @@ Pre-requisites
```

</details>
- if you are not on the most recent version of OSX, `homebrew`
- this allows us to install the current version of cocoapods without
running into ruby incompatibilities - e.g.
https://github.com/CocoaPods/CocoaPods/issues/11763

Important
---
Expand Down
9 changes: 7 additions & 2 deletions setup/export_shared_dep_versions.sh
Original file line number Diff line number Diff line change
@@ -1,9 +1,14 @@
export NVM_VERSION=0.39.0
export NODE_VERSION=14.18.1
export NPM_VERSION=6.14.15
export RUBY_VERSION=2.6.0
# make sure that this is a stable version from
# so that https://github.com/postmodern/ruby-versions
# ideally, this would be the same version as the CI
# Looks like brew supports only major and minor, not patch version
export RUBY_VERSION=2.7
export COCOAPODS_VERSION=1.11.2
export GRADLE_VERSION=7.1.1
export OSX_EXP_VERSION=12

export NVM_DIR="$HOME/.nvm"
export RUBY_PATH=$HOME/.gem/ruby/$RUBY_VERSION/bin
export RUBY_PATH=$HOME/.gem/ruby/$RUBY_VERSION.0/bin
46 changes: 27 additions & 19 deletions setup/setup_ios_native.sh
Original file line number Diff line number Diff line change
Expand Up @@ -4,26 +4,34 @@ set -e
# Setup the development environment
source setup/setup_shared.sh

# Importing rvm keys
curl -sSL https://rvm.io/mpapis.asc | gpg2 --import -
curl -sSL https://rvm.io/pkuczynski.asc | gpg2 --import -

# Download and install rvm
echo "Installing stable rvm"
curl -sSL https://get.rvm.io | bash -s stable

# Enable rvm
source /Users/kshankar/.rvm/scripts/rvm

# Download and install ruby
echo "Installing ruby $RUBY_VERSION"
rvm install ruby-$RUBY_VERSION

echo "Switching to ruby version $RUBY_VERSION"
rvm use $RUBY_VERSION

OSX_MAJOR_VERSION=`sw_vers | grep ProductVersion | cut -d ':' -f 2 | cut -d '.' -f 1`
echo "Found OSX major version" $OSX_MAJOR_VERSION

CURR_RUBY_VERSION=`ruby --version | cut -d ' ' -f 2 | cut -d '.' -f 1-2`
echo "Found ruby version "$CURR_RUBY_VERSION

if [ $CURR_RUBY_VERSION == $RUBY_VERSION ]; then
echo "Found ruby version "$CURR_RUBY_VERSION" expected "$RUBY_VERSION" no need to upgrade"
else
if [ -x /usr/local/bin/brew ]; then
echo "Found brew installation with version" `/usr/local/bin/brew --version`
echo "Installing ruby version to brew" $RUBY_VERSION
brew install ruby@$RUBY_VERSION
else
if [ $OSX_MAJOR_VERSION -ge $OSX_EXP_VERSION ]; then
echo "No brew installation found, but OSX major version "$OSX_MAJOR_VERSION" and expected version "$OSX_EXP_VERSION" so CocoaPods should work"
else
echo "No brew installation found, but OSX major version "$OSX_MAJOR_VERSION" != expected version "$OSX_EXP_VERSION" CocoaPods install will likely fail"
echo "Found ruby version "`ruby --version`
exit 1
fi
fi
fi

echo "Adding $RUBY_PATH to the path before the install"
export PATH=$RUBY_PATH:$PATH

echo "Installing cocoapods"
gem install --no-document --user-install cocoapods -v $COCOAPODS_VERSION
/usr/local/opt/ruby@$RUBY_VERSION/bin/gem install --no-document --user-install cocoapods -v $COCOAPODS_VERSION

source setup/setup_shared_native.sh

0 comments on commit 2126a73

Please sign in to comment.