From 591e2ed231c0607e96935486d6f03eddba1ae093 Mon Sep 17 00:00:00 2001 From: "K. Shankari" Date: Fri, 10 Feb 2023 14:49:42 -0800 Subject: [PATCH 1/4] Lock down the version of ruby used instead of "the default" - install rvm, just like we install nvm - this involves importing keys so that the rvm install can be validated - source the script - install the desired version of ruby - use that to install the correct version of cocoapods --- setup/setup_ios_native.sh | 20 +++++++++++++++++++- 1 file changed, 19 insertions(+), 1 deletion(-) diff --git a/setup/setup_ios_native.sh b/setup/setup_ios_native.sh index 3e02c2f57..16c04118f 100644 --- a/setup/setup_ios_native.sh +++ b/setup/setup_ios_native.sh @@ -4,8 +4,26 @@ set -e # Setup the development environment source setup/setup_shared.sh -echo "Installing cocoapods" +# 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 + export PATH=$RUBY_PATH:$PATH +echo "Installing cocoapods" gem install --no-document --user-install cocoapods -v $COCOAPODS_VERSION source setup/setup_shared_native.sh From 7e1c71ef428d06196553a44a7f23685f9a373835 Mon Sep 17 00:00:00 2001 From: "K. Shankari" Date: Fri, 10 Feb 2023 16:41:21 -0800 Subject: [PATCH 2/4] Print the brew and ruby versions so that we can make sure to be consistent --- .github/workflows/ios-build.yml | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/.github/workflows/ios-build.yml b/.github/workflows/ios-build.yml index 4f520c950..62b2ccb0d 100644 --- a/.github/workflows/ios-build.yml +++ b/.github/workflows/ios-build.yml @@ -32,6 +32,11 @@ jobs: - name: Print the xcode setup run: xcodebuild -version -sdk + - name: Print the brew and ruby versions + run: | + echo "brew version is "`brew --version` + echo "ruby version is" `ruby --version` + - name: Print applications through dmg run: ls /Applications From c67cdc6440604c84005868a90c83b27336a219e8 Mon Sep 17 00:00:00 2001 From: "K. Shankari" Date: Fri, 10 Feb 2023 19:48:23 -0800 Subject: [PATCH 3/4] Ensure that the activate script doesn't crash when the ANDROID_SDK_ROOT and ANDROID_HOME are not set Because if we do `exit 1` and then `source setup/activate_native.sh` then the bash terminal dies --- setup/activate_native.sh | 1 - 1 file changed, 1 deletion(-) diff --git a/setup/activate_native.sh b/setup/activate_native.sh index c0b8eb6e3..c1014c987 100644 --- a/setup/activate_native.sh +++ b/setup/activate_native.sh @@ -8,7 +8,6 @@ echo "Verifying $ANDROID_HOME or $ANDROID_SDK_ROOT is set" if [ -z $ANDROID_HOME ] && [ -z $ANDROID_SDK_ROOT ]; then echo "ANDROID_HOME and ANDROID_SDK_ROOT not set, android SDK not found" - exit 1 fi echo "Activating sdkman, and by default, gradle" From 2126a738bcb775d71bffc44490b52a6f752d3320 Mon Sep 17 00:00:00 2001 From: "K. Shankari" Date: Fri, 10 Feb 2023 19:52:33 -0800 Subject: [PATCH 4/4] Actually install the correct version of ruby to install cocoapods - 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 --- README.md | 4 +++ setup/export_shared_dep_versions.sh | 9 ++++-- setup/setup_ios_native.sh | 46 +++++++++++++++++------------ 3 files changed, 38 insertions(+), 21 deletions(-) diff --git a/README.md b/README.md index c9b029ec0..85fc73f21 100644 --- a/README.md +++ b/README.md @@ -120,6 +120,10 @@ Pre-requisites ``` +- 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 --- diff --git a/setup/export_shared_dep_versions.sh b/setup/export_shared_dep_versions.sh index 123580155..74ffb7087 100644 --- a/setup/export_shared_dep_versions.sh +++ b/setup/export_shared_dep_versions.sh @@ -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 diff --git a/setup/setup_ios_native.sh b/setup/setup_ios_native.sh index 16c04118f..07cd0e977 100644 --- a/setup/setup_ios_native.sh +++ b/setup/setup_ios_native.sh @@ -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