Skip to main content

ERROR FIX(React Native): Installing Ruby Gems, error Your Ruby version is 2.6.8 but your Gemfile specified >= 2.6.10

Fixing React Native iOS Build Errors

If you're encountering the following errors while building your React Native project:

ERROR FIX: Installing Ruby Gems, error Your Ruby version is 2.6.8 but your Gemfile specified >= 2.6.10, error Looks like your 10S environment is not properly set. Please go to React Native Environment Setup and follow the React Native CLI QuickStart guide for macOS and iOS.

This issue is occurring due to a Ruby version mismatch. To resolve it, follow these steps:

Step 1: Install rbenv using Homebrew

brew install rbenv ruby-build

If Homebrew is not installed, you can install it from the Homebrew website. Use the following commands to install Homebrew:


/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"
(echo; echo 'eval "$(/usr/local/bin/brew shellenv)"') >> /Users/<your username>/.zprofile
eval "$(/usr/local/bin/brew shellenv)"
    

To check if the path is set correctly, run:

vi ~/.zprofile

Step 2: Check rbenv path

vi ~/.zhrc

Check if the following line is already present (Add it if it's not already there.):

eval "$(rbenv init - zsh)"

Step 3: Check for the Latest Ruby Version

rbenv install -l

Step 4: Install the Latest Ruby Version

rbenv install 3.2.2

Replace "3.2.2" with the latest version if it's different.

Step 5: Set Ruby Version as Default

rbenv global 3.2.2

Step 6: Verify Ruby Installation

ruby -v

Your output should look similar to this:

ruby 3.2.2 (2023-03-30 revision e51014f9c0) [x86_64-darwin21]

If not, please reset the terminal.

Step 7: Finally, run the following commands in your project directory.

cd <your project folder>
bundle update
bundle install
cd ios
pod repo update
bundle exec pod install
    

It should work now. If the issue persists, make the following change in your "<your project folder>/Gemfile" (open Gemfile in any text editor):


# Comment the previous line (e.g., gem 'activesupport', '>= 6.1.7.3', '< 7.1.0')
gem 'activesupport', '~> 7.0', '<= 7.0.8'
    

That should resolve the Ruby version mismatch issue. Happy coding!

Comments

Popular posts from this blog

Setup Mac Machine for React Native development

Setting Up a Mac Machine for React Native Development React Native is a popular framework for building mobile apps using JavaScript and React. To get started with React Native development on your Mac machine, follow these steps: Setup iOS Environment Install Xcode: You can install Xcode from the App Store . If you need a specific version, refer to this stack overflow link . Open Xcode and install any required tools. Install Homebrew (which also installs Command Line Tools): /bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)" Then set the path: (echo; echo 'eval "$(/usr/local/bin/brew shellenv)"') >> /Users/<your username>/.zprofile eval "$(/usr/local/bin/brew shellenv)" To check if the path is set correctly: vi ~/.zprofile Install Node using Homebrew: ...