skip to Main Content

I have installed node@16(v16.18.0) in macOS and npm version: 8.19.2.

  • Operating System macOS(Monterey) version: 12.6
  • Xcode Verion: 14.0.1

Followed some instructions to setup react-native environment in my devices using bellow steps are mentioned:

  1. Homebrew install(Version: 3.6.7 ): /bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"
  2. watchman install(Version: 2022.10.24.00): brew install watchman
  3. Install Ruby(version: 2.6.8p205): brew install ruby
  4. Install CocoaPods(gem version: 3.0.3.1): sudo gem install cocoapods
  5. CocoaPods in fixed location(pod version: 1.11.3): sudo gem install -n /usr/local/bin ffi cocoapods

After successfully installed all of the aboves I was going to create react-native app using npx react-native init AwesomeProject comand and faced Your Ruby version is 2.6.8, but your Gemfile specified 2.7.5 error is also given in attached file. please check it and help me to suggest the way to solved.

uby version is 2.6.8, but your Gemfile specified 2.7.5

All of the resourses are mentioned below which I have follwed to solved this issues but i didn’t solve it.

  1. How to fix "Your Ruby version is 2.3.0, but your Gemfile specified 2.2.5" while server starting
  2. Your Ruby version is 2.5.1 but your Gemfile specified 2.4.0
  3. rbenv Your Ruby version is 2.0.0, but your Gemfile specified 2.1.2

12

Answers


  1. Chosen as BEST ANSWER

    Below are the instructions which I have followed to solve this issue:

    1. Homebrew install: /bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"
    2. watchman install: brew install watchman
    3. Install Ruby: followed rbenv Official Github Repo link to install the required version of ruby
    4. Install CocoaPods: sudo gem install cocoapods
    5. CocoaPods in fixed location: sudo gem install -n /usr/local/bin ffi cocoapods

    After the environment setup, it works perfectly.


  2. You need to install the correct Ruby version. And it would be best if you use some ruby version manager for that. For example rbenv.

    You can try these commands to install and change global Ruby version to 2.7.5

    $ brew update
    $ brew install ruby-build
    $ brew install rbenv
    
    $ rbenv install 2.7.5
    $ rbenv global 2.7.5
    

    After that, you need to export some configurations to define rbenv as default global ruby:

    echo 'export PATH="$HOME/.rbenv/bin:$PATH"' >> ~/.zshrc
    echo 'eval "$(rbenv init -)"' >> ~/.zshrc
    
    Login or Signup to reply.
  3. As Alexander says use rbenv or rvm to manage your ruby version. MacOS automatically brings a native version of ruby. You should avoid to update or change your native (MacOS) ruby version.

    Further information why not to use system ruby and what are common issues: https://mac.install.guide/faq/do-not-use-mac-system-ruby/index.html

    Login or Signup to reply.
  4. I had the same problem with these exact versions. This was the solution for me: Fix Your Ruby version is 2.6.8, but your gemfile specified 2.5.5

    Login or Signup to reply.
  5. check version of your ruby first

    ruby -v
    

    if isn’t 2.7.5 you must roll your version to 2.7.5

    rvm install "ruby-2.7.5"
    rvm use ruby-2.7.5 --default
    
    Login or Signup to reply.
  6. Found solution for me:

    1. Clear ~/Library/Caches folder
    2. Make sure you are using the latest required by react-native ruby version
    ruby -v
    
    1. Reboot terminal and try again
    Login or Signup to reply.
  7. This works ok! rvm use ruby-2.7.5 –default

    Login or Signup to reply.
  8. Can also use asdf to install it with asdf install ruby 2.7.5 (or whatever version is needed)

    Then switch using asdf global ruby 2.7.5 and re-run your command.

    See https://asdf-vm.com/guide/getting-started.html to get started with asdf

    Login or Signup to reply.
  9. For me, i just went to my react native project folder, and open the GemFile, update the ruby version as the error msg suggests, then the error gone, Good luck.

    enter image description here

    Login or Signup to reply.
  10. Run this command inside the directory where you want to create the new app, to check the list of available ruby versions:

    $ rvm list

    if you get this message: # No rvm rubies installed yet. Try 'rvm help install'.

    Then run:

    $ rvm install 2.7.5 to install this specific version of ruby.

    After installation is successful, run this command to make it default: $ rvm use ruby-2.7.5 --default

    run again: $ rvm list to make sure that ruby-2.7.5 is selected as default

    if you see something like this:

     =*ruby-2.7.5 [ x86_64 ]
       ruby-2.7.6 [ x86_64 ](other available version)
       ruby-3.0.0 [ x86_64 ](other available version)
    
    # => - current
    # =* - current && default
    #  * - default
    

    then you are good to go, you can safely run your command:

    npx react-native init AwesomeProject

    and everything should work as expected.

    Login or Signup to reply.
  11. See https://github.com/facebook/react-native/issues/35873

    The guy who had the same problem with me, just fixed issue (including me)
    right after deleting /usr/local/bin/bundle

    Try this one after following all above instuctions and still getting issue

    Login or Signup to reply.
  12. Welp, actually no answer solved my issue.
    This happens even if your ruby version is correct when you run "npx react-native@latest init AwesomeProject".
    But I found the solution.
    When you see this error, you will still see the project folder created.
    Go to the ios folder and run

    bundle install && bundle exec pod install
    

    problem solved.

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search