Home > Software engineering >  Error initializing React Native app: "Your Ruby version is 2.6.10, but your Gemfile specified 2
Error initializing React Native app: "Your Ruby version is 2.6.10, but your Gemfile specified 2

Time:12-04

I know similar questions exist.

I've gone through most of them but, so far, none of the solutions worked.

Here is the context:

Operating system: macOS Ventura 13.0.1 (Intel processor)

Here are some commands output:

$ ruby -v
ruby 2.7.5p203 (2021-11-24 revision f69aeb8314) [x86_64-darwin22]
$ which ruby
/Users/..../.rbenv/shims/ruby
$  bundler -v
Bundler version 2.3.26
$ which bundler
/Users/..../.rbenv/shims/bundler

My ~/.bash_profile and ~/.zshrc contain:

export PATH="$HOME/.rbenv/bin:$PATH"
eval "$(rbenv init -)"
export PATH="$HOME/.rbenv/shims:$PATH"
eval "$(rbenv init -)"

I know nothing about ruby, I'm using rbenv to manage ruby versions.

I've done a similar setup on another macOS system but for some reason, on this system, nothing I have tried works.

Any helps is appreciated.

Thanks.

CodePudding user response:

In the directory where you run npx react-native init, try following code :

rbenv init
rbenv shell 2.7.5
eval "$(rbenv init - bash)";

CodePudding user response:

I've managed to make it work.

I'm not sure what did it.

I've upgraded node from 14 to 19 which also upgraded react-native to 0.70.6

Also, I've added if which rbenv > /dev/null; then eval "$(rbenv init -)"; fi to .bash_profile and .zshrc

  • Related