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:
- Homebrew install(Version: 3.6.7 ):
/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"
- watchman install(Version: 2022.10.24.00):
brew install watchman
- Install Ruby(version: 2.6.8p205):
brew install ruby
- Install CocoaPods(gem version: 3.0.3.1):
sudo gem install cocoapods
- 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.
All of the resourses are mentioned below which I have follwed to solved this issues but i didn’t solve it.
12
Answers
Below are the instructions which I have followed to solve this issue:
/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"
brew install watchman
sudo gem install cocoapods
sudo gem install -n /usr/local/bin ffi cocoapods
After the environment setup, it works perfectly.
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
After that, you need to export some configurations to define rbenv as default global ruby:
As Alexander says use
rbenv
orrvm
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
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
check version of your ruby first
if isn’t 2.7.5 you must roll your version to 2.7.5
Found solution for me:
This works ok! rvm use ruby-2.7.5 –default
Can also use
asdf
to install it withasdf 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
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.
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 thatruby-2.7.5
is selected as defaultif you see something like this:
then you are good to go, you can safely run your command:
npx react-native init AwesomeProject
and everything should work as expected.
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
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
problem solved.