Reputation: 1855
I have installed node@16(v16.18.0
) in macOS and npm version: 8.19.2
.
12.6
14.0.1
Followed some instructions to setup react-native environment in my devices using bellow steps are mentioned:
/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"
brew install watchman
brew install ruby
sudo gem install cocoapods
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.
Upvotes: 47
Views: 78636
Reputation: 1
this worked for me:
Operating system - macOS Monterey
version - 12.5.1
chip - Apple M2
steps to reproduce
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
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
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
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
Reputation: 55
Just edit the Gemfile type nano Gemfile on terminal window to open Gemfile it should look like this
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
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
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
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
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.
Upvotes: 0
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
Reputation: 11
Found solution for me:
ruby -v
Upvotes: 1
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
Reputation: 1855
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.
Upvotes: 15
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