React Native build error by ruby
배석현 책임
RN build error by ruby
어제 @Leona(이윤영) 가 React Native 신규 프로젝트를 만들었는데 pod install하면 오류가 발생했다. 내 Macbook에서 RN 새프로젝트를 만들면 어떻게 되는지 확인을 했다.
PART1
$npx react-native init MyApp --template react-native-template-typescript
npx: 605개의 패키지를 53.763초만에 설치했습니다.
###### ######
### #### #### ###
## ### ### ##
## #### ##
## #### ##
## ## ## ##
## ### ### ##
## ######################## ##
###### ### ### ######
### ## ## ## ## ###
### ## ### #### ### ## ###
## #### ######## #### ##
## ### ########## ### ##
## #### ######## #### ##
### ## ### #### ### ## ###
### ## ## ## ## ###
###### ### ### ######
## ######################## ##
## ### ### ##
## ## ## ##
## #### ##
## #### ##
## ### ### ##
### #### #### ###
###### ######
Welcome to React Native!
Learn once, write anywhere
✔ Downloading template
✔ Copying template
✔ Processing template
✖ Installing Bundler
error Your Ruby version is 2.6.8, but your Gemfile specified 2.7.5
✖ 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.
이전 프로젝트에서는 문제가 없었는데, 무언가 오류가 발생했다❗
에러 메시지에 나와 있는 페이지를 방문해 보자.
https://reactnative.dev/docs/next/environment-setup
조금 내려가 보면 루비 관련된 얘기가 있다.
루비 버전을 확인해 보자
$ruby --version
ruby 2.6.8p205 (2021-07-07 revision 67951) [universal.arm64e-darwin21]
Node 처럼 루비도 버전 관리가 필요할 것 같다.
그래서 rbenv로 해당 버전을 설치하자. 위 오류 메시지에서 2.7.5가 없다고 하니 2.7.5를 설치하자
$brew update
$brew install rbenv ruby-build
$rbenv install 2.7.5
$rbenv global 2.7.5
$rbenv version
$vi ~/.zshrc
[[ -d ~/.rbenv ]] && \
export PATH=${HOME}/.rbenv/bin:${PATH} && \
eval "$(rbenv init -)"
$source ~/.zshrc
$rbenv versions
이제 기존 프로젝트는 삭제하고 다시 프로젝트를 만들자
$npx react-native init MyApp --template react-native-template-typescript
npx: 605개의 패키지를 36.586초만에 설치했습니다.
###### ######
### #### #### ###
## ### ### ##
## #### ##
## #### ##
## ## ## ##
## ### ### ##
## ######################## ##
###### ### ### ######
### ## ## ## ## ###
### ## ### #### ### ## ###
## #### ######## #### ##
## ### ########## ### ##
## #### ######## #### ##
### ## ### #### ### ## ###
### ## ## ## ## ###
###### ### ### ######
## ######################## ##
## ### ### ##
## ## ## ##
## #### ##
## #### ##
## ### ### ##
### #### #### ###
###### ######
Welcome to React Native!
Learn once, write anywhere
✔ Downloading template
✔ Copying template
✔ Processing template
✔ Installing Bundler
✔ Installing CocoaPods dependencies (this may take a few minutes)
Run instructions for Android:
• Have an Android emulator running (quickest way to get started), or a device connected.
• cd "/Users/shb/Dev/MyApp" && npx react-native run-android
Run instructions for iOS:
• cd "/Users/shb/Dev/MyApp" && npx react-native run-ios
- or -
• Open MyApp/ios/MyApp.xcworkspace in Xcode or run "xed -b ios"
• Hit the Run button
Run instructions for macOS:
• See https://aka.ms/ReactNativeGuideMacOS for the latest up-to-date instructions.
잘 된다!
PART2
신규 프로젝트는 이제 잘 되는 것 같다.
그런데 기존 프로젝트에서 pod install 하면 문제가 발생한다…
$pod install
Using firebase.json from '/Users/shb/Dev/mcas-react-native-lsp/firebase.json'
Adding a custom script phase for Pod RNFBApp: [RNFB] Core Configuration
Adding a custom script phase for Pod RNFBCrashlytics: [RNFB] Crashlytics Configuration
Auto-linking React Native modules for target `MCASReactNative`: CodePush, RNAWSCognito, RNCAsyncStorage, RNCPushNotificationIOS, RNFBApp, RNFBCrashlytics, RNFBMessaging, RNFastImage, RNGestureHandler, RNImageCropPicker, RNLocalize, RNPermissions, RNReanimated, RNSVG, RNScreens, RNVectorIcons, goparrot-react-native-geometry-utils, react-native-camera, react-native-document-picker, react-native-geolocation-service, react-native-get-random-values, react-native-maps, react-native-netinfo, react-native-pager-view, react-native-safe-area-context, react-native-splash-screen, react-native-version-check, and rn-fetch-blob
Analyzing dependencies
Fetching podspec for `DoubleConversion` from `../node_modules/react-native/third-party-podspecs/DoubleConversion.podspec`
Fetching podspec for `RCT-Folly` from `../node_modules/react-native/third-party-podspecs/RCT-Folly.podspec`
Fetching podspec for `glog` from `../node_modules/react-native/third-party-podspecs/glog.podspec`
/Library/Ruby/Gems/2.6.0/gems/ffi-1.15.5/lib/ffi/library.rb:275: [BUG] Bus Error at 0x0000000102200000
ruby 2.6.8p205 (2021-07-07 revision 67951) [universal.arm64e-darwin21]
-- Crash Report log information --------------------------------------------
See Crash Report log file under the one of following:
* ~/Library/Logs/DiagnosticReports
* /Library/Logs/DiagnosticReports
for more details.
Don't forget to include the above Crash Report log file in bug reports.
보면 루비 문제는 아닌 것 같다.
오류 메시지 끝 쪽에 보면 ffi 하는 부분이 있다. (위 로그에는 생략된 부분이다.)
그래서 m1과 ffi로 구글링해 봤다. 아래와 같이 실행하고 pod install 하자
$sudo arch -x86_64 gem install ffi
$arch -x86_64 pod install
...
Generating Pods project
Integrating client project
Pod installation complete! There are 86 dependencies from the Podfile and 95 total pods installed.
정상적으로 된다.