Imdadul Haque
Imdadul Haque

Reputation: 1855

Your Ruby version is 2.6.8, but your Gemfile specified 2.7.5

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

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

Upvotes: 47

Views: 78636

Answers (15)

Nagendra
Nagendra

Reputation: 1

this worked for me:

Operating system - macOS Monterey

version - 12.5.1

chip - Apple M2

steps to reproduce

  1. npx react-native@latest init AwesomeProject

error: your ruby-version is 2.6.8, but your gemfile specified is 2.6.10

https://mac.install.guide/ruby/13.html

Upvotes: 0

Arinzehills
Arinzehills

Reputation: 2329

In my own case since the project folder is created, i went to the ios folder

cd ios 

and i open gem file and added this:

gem 'activesupport', '~> 6.1.5'

and then bundle install and it worked

Upvotes: 0

Alexander
Alexander

Reputation: 1336

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. For zsh users:

echo 'export PATH="$HOME/.rbenv/bin:$PATH"' >> ~/.zshrc
echo 'eval "$(rbenv init -)"' >> ~/.zshrc

And restart the terminal or run source ~/.zshrc.

For bash users just replace zshrc with bashrc in the above.

Upvotes: 104

Anurag Banger
Anurag Banger

Reputation: 41

If you are not able to find a fix to update the ruby version for a local project after going through the above solutions, I found one on ruby documentions. The rbenv documentation was also helpful to understand the issue.

RubyGems’ default local repository can be overridden with the GEM_PATH and GEM_HOME environment variables. GEM_HOME sets the default repository to install into. GEM_PATH allows multiple local repositories to be searched for gems.

Update the latest installed ruby version as default by copying the rbenv installed directory location found using gem env home and then past it in the ~/.zshrc file under export GEM_HOME=<directory-path>.

After this, if you check the ruby version inside your project you will get the latest global version set by you from rbenv, eg:- rbenv global 3.2.2.

Once the version is set in your local project you can install the bundler and update the cocoapods.

Upvotes: 1

Apatoallo
Apatoallo

Reputation: 55

Just edit the Gemfile type nano Gemfile on terminal window to open Gemfile it should look like this

enter image description here

and just change ruby'2.7.5' version to which ruby version you want to specify your gemfile and control+X to save it you can specify your gemfile with any ruby version you need for the react native project 2.7.6 version is required for now

Upvotes: 0

Junho Lee
Junho Lee

Reputation: 328

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.

Upvotes: 2

Orange Fritters
Orange Fritters

Reputation: 1

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

Upvotes: 0

Israr Khan
Israr Khan

Reputation: 21

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.

Upvotes: 1

ItwasJJsmile
ItwasJJsmile

Reputation: 109

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

Upvotes: 0

Montana Harkin
Montana Harkin

Reputation: 419

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

Upvotes: 0

Ivan Viveros
Ivan Viveros

Reputation: 21

This works ok! rvm use ruby-2.7.5 --default

Upvotes: 1

Sergey Morozov
Sergey Morozov

Reputation: 11

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

Upvotes: 1

Borbyu
Borbyu

Reputation: 166

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

Upvotes: 13

Imdadul Haque
Imdadul Haque

Reputation: 1855

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.

Upvotes: 15

Christian
Christian

Reputation: 31

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

Upvotes: 2

Related Questions