react-native: [0.71.0] npx react-native init always use system ruby version in macos and throw bundle installer error
Description
I always face this error:
✖ Installing Bundler
error Your Ruby version is 2.6.10, but your Gemfile specified 2.7.6
✖ Installing Bundler
error Error: Looks like your iOS environment is not properly set. Please go to https://reactnative.dev/docs/next/environment-setup and follow the React Native CLI QuickStart guide for macOS and iOS.
Error: Error: Looks like your iOS environment is not properly set. Please go to https://reactnative.dev/docs/next/environment-setup and follow the React Native CLI QuickStart guide for macOS and iOS.
at createFromTemplate (/Users/techcity/.npm/_npx/7930a8670f922cdb/node_modules/@react-native-community/cli/build/commands/init/init.js:129:11)
at process.processTicksAndRejections (node:internal/process/task_queues:95:5)
at async Object.initialize [as func] (/Users/techcity/.npm/_npx/7930a8670f922cdb/node_modules/@react-native-community/cli/build/commands/init/init.js:181:3)
at async Command.handleAction (/Users/techcity/.npm/_npx/7930a8670f922cdb/node_modules/@react-native-community/cli/build/index.js:106:9)
info Run CLI with --verbose flag for more details.
when running npx react-native init project_name
I investigate and found it’s showing in my system default ruby version is: 2.6.10 .
The error is: error Your Ruby version is 2.6.10, but your Gemfile specified 2.7.6
But i installed ruby version: 2.7.6 in my mac using rbenv.
heres my details:
╰─ rbenv versions ─╯
system
2.7.5
* 2.7.6 (set by /Users/techcity/.rbenv/version)
╰─ ruby -v ─╯
ruby 2.7.6p219 (2022-04-12 revision c9c2245c0a) [x86_64-darwin21]
i also tried this: rbenv global 2.7.6
but also throwing same error on every new project init.
Everytime when creating new project it’s throw error of bundle install, and then i have to go manually project dir, then need to run : bundle install
then it’s get fixed.
Please fix this bug, so react native can choose the user selected ruby version.
You can add also a functionality where if in user computer multiple ruby version installed, then you can ask user to choice ruby version.
it will be best for everyone.
Version
0.71.0
Output of npx react-native info
System: OS: macOS 12.6.2 CPU: (4) x64 Intel® Core™ i5-5257U CPU @ 2.70GHz Memory: 32.90 MB / 8.00 GB Shell: 5.8.1 - /bin/zsh Binaries: Node: 18.6.0 - /usr/local/bin/node Yarn: 1.22.19 - /usr/local/bin/yarn npm: 8.15.1 - /usr/local/bin/npm Watchman: 2022.10.03.00 - /usr/local/bin/watchman Managers: CocoaPods: 1.11.3 - /usr/local/bin/pod SDKs: iOS SDK: Platforms: DriverKit 22.2, iOS 16.2, macOS 13.1, tvOS 16.1, watchOS 9.1 Android SDK: Not Found IDEs: Android Studio: 2022.1 AI-221.6008.13.2211.9477386 Xcode: 14.2/14C18 - /usr/bin/xcodebuild Languages: Java: 11.0.16 - /usr/bin/javac npmPackages: @react-native-community/cli: Not Found react: 18.2.0 => 18.2.0 react-native: 0.71.0 => 0.71.0 react-native-macos: Not Found npmGlobalPackages: react-native: Not Found
Steps to reproduce
╰─ rbenv versions ─╯
system
2.7.5
* 2.7.6 (set by /Users/techcity/.rbenv/version)
╰─ ruby -v ─╯
ruby 2.7.6p219 (2022-04-12 revision c9c2245c0a) [x86_64-darwin21]
i also tried this: rbenv global 2.7.6
Snack, code example, screenshot, or link to a repository
npx react-native init TsApp --template react-native-template-typescript
About this issue
- Original URL
- State: closed
- Created a year ago
- Reactions: 2
- Comments: 80 (17 by maintainers)
I had the same problem last week. In my case I had to install version 2.7.5 and set PATHs in .zshrc. Try these steps:
rbenv install 2.7.6 && rbenv global 2.7.6
echo 'eval "$(rbenv init -)"' >> ~/.zshrc
source ~/.zshrc
/usr/local/bin/bundle
THanks man thats fixed my issue also, successfully working now
this fixed my issue… thank you so much @DimitarNestorov for you hard work… Finally initialized the 0.71.0 successfully…
It’s making problem everytime when trying to create new project. Because in my macos by default ruby version 2.6.10 is installed. But i installed ruby version 2.7.6 by using rbenv and setup done for global.
When i run:
ruby -v
it;s showing me ruby version 2.7.6 is installed, but when doing init react native project, then react native taking older version ruby from system default.We need a fix for that.
done remove, let me try now
absolutely same issue on me.
Thanks
step by step, in teriminal, 1.echo ‘if which rbenv > /dev/null; then eval “$(rbenv init -)”; fi’ >> ~/.zshrc 2.source ~/.zshrc 3.rbenv global 2.6.10
fix my error
So many commands, so much time working on this problem. im going to tatoo this: sudo rm -rf /usr/local/bin/bundle
I think the only solution is for that:
When we will run:
npx react-native init project_name
That time react native cli need to check how many versions are installed on the computer, and the react-native need to ask the developer that, what version of ruby the developer want to use for this project. That will fix the problem permanently.