0

I'm trying to correct the issue in my react native setup, the issue seems to be ruby. To clarify I'm on a Mac M1

So i installed rvm, installed rvm 2.7.6 (which is the current version of ruby react native uses, information taken on their website). I did this command on Rosetta2 because it was crashing in a non-rosetta terminal : rvm install 2.7.6

The rest of the command are NOT done in Rosetta2.

Then I added rvm to the my ~/.zshrc file

export PATH="$PATH:$HOME/.rvm/gems/ruby-2.7.6/bin"
export PATH="$PATH:$HOME/.rvm/bin"

well actually, I added those two lines with the command rvm get stable --auto-dotfiles

Sometimes, I still get this error, I have to admit that I don't know why, I understood that the line above was supposed to add it to the path. Warning! PATH is not properly set up, /Users/myusername/.rvm/gems/ruby-2.7.6/bin is not at first place.

Anyway, I do this then :

rvm --default use 2.7.6
ruby --version

the last line return this : ruby 2.7.6p219 (2022-04-12 revision c9c2245c0a) [x86_64-darwin22]

which sounds okay to me, so I try to init a new project with react native : npx react-native init NewProject

Then I got something suspicious, react native telling me to download cocoapods either with gem or home-brew, but I already did it with gem. Anyway I select download with gem (or Homebrew, both result have the same error). And I got this error : Your Ruby version is 2.6.10, but your Gemfile specified 2.7.6

Re-checked the ruby version, still the 2.7.6, I'm missing something, and maybe more than just one thing but I've been on a lot of post and stuff and can't find the solution so I'm trying here.

Madar
  • 196
  • 2
  • 15
  • Installing RVM and Ruby using Rosetta was a mistake. My recommendation: completely remove RVM and start over. I don't recommend you use RVM. Use [rbenv](https://github.com/rbenv/rbenv) or [asdf](https://asdf-vm.com/) and do not use Rosetta. **Follow the setup instructions exactly and with great care**. [This answer](https://stackoverflow.com/a/74942677/3784008) likely explains your error message about `Your Ruby version is 2.6.10`. My very short answer is: you are not carefully and exactly following the setup instructions for Ruby or for React Native. Start over and follow the instructions. – anothermh Feb 02 '23 at 16:32

1 Answers1

1

have you tried to remove the /usr/local/bin/bundle file and then run again ?

source : https://github.com/facebook/react-native/issues/35873#issuecomment-1397226452

Here are some alternative you can try too :

Pierre Marsaa
  • 346
  • 2
  • 10
  • I just tried, the init works but I can't run it later. It gave me an error 65 about Xcode. It stills asks me to install CocoaPods EVERY time I init a new project so I don't think it's actually the good solution. – Madar Feb 02 '23 at 10:45