facebook / react-native

A framework for building native applications using React
https://reactnative.dev
MIT License
117.85k stars 24.16k forks source link

Your RubyGems version (3.0.3.1) has a bug that prevents `required_ruby_version` from working for Bundler #37301

Closed starterProgrammer closed 1 year ago

starterProgrammer commented 1 year ago

Description

i am trying to install react native and give many errors for two days.please help me to fix my errors I tried to install everythings are explained here 'https://reactnative.dev/docs/environment-setup?guide=native' but at least when i run init project gives me error

Screen Shot 1402-02-18 at 12 21 59

error Your RubyGems version (3.0.3.1) has a bug that preventsrequired_ruby_versionfrom working for Bundler. Any scripts that usegem install bundlerwill break as soon as Bundler drops support for your Ruby version. Please upgrade RubyGems to avoid future breakage and silence this warning by runninggem update --system 3.2.3Gem::Ext::BuildError: ERROR: Failed to build gem native extension. current directory: /Users/apple/Desktop/template/vendor/bundle/ruby/2.6.0/gems/ffi-1.15.5/ext/ffi_c /System/Library/Frameworks/Ruby.framework/Versions/2.6/usr/bin/ruby -I /System/Library/Frameworks/Ruby.framework/Versions/2.6/usr/lib/ruby/2.6.0 -r ./siteconf20230508-4891-11u18l.rb extconf.rb --enable-system-libffi checking for ffi_prep_closure_loc() in -lffi... no checking for ffi_prep_closure_loc() in -llibffi... no checking for ffi_prep_closure_loc() in -llibffi-8... no system libffi is not usable *** extconf.rb failed *** Could not create Makefile due to some reason, probably lack of necessary libraries and/or headers. Check the mkmf.log file for more details. You may need configuration options. Provided configuration options: --with-opt-dir --without-opt-dir --with-opt-include --without-opt-include=${opt-dir}/include --with-opt-lib --without-opt-lib=${opt-dir}/lib --with-make-prog --without-make-prog --srcdir=. --curdir --ruby=/System/Library/Frameworks/Ruby.framework/Versions/2.6/usr/bin/$(RUBY_BASE_NAME) --with-ffi_c-dir --without-ffi_c-dir --with-ffi_c-include --without-ffi_c-include=${ffi_c-dir}/include --with-ffi_c-lib --without-ffi_c-lib=${ffi_c-dir}/lib --enable-system-libffi --with-libffi-config --without-libffi-config --with-pkg-config --without-pkg-config --with-ffilib --without-ffilib --with-libffilib --without-libffilib --with-libffi-8lib --without-libffi-8lib To see why this extension failed to compile, please check the mkmf.log which can be found here: /Users/apple/Desktop/template/vendor/bundle/ruby/2.6.0/extensions/universal-darwin-21/2.6.0/ffi-1.15.5/mkmf.log extconf failed, exit code 1 Gem files will remain installed in /Users/apple/Desktop/template/vendor/bundle/ruby/2.6.0/gems/ffi-1.15.5 for inspection. Results logged to /Users/apple/Desktop/template/vendor/bundle/ruby/2.6.0/extensions/universal-darwin-21/2.6.0/ffi-1.15.5/gem_make.out /System/Library/Frameworks/Ruby.framework/Versions/2.6/usr/lib/ruby/2.6.0/rubygems/ext/builder.rb:99:inrun' /System/Library/Frameworks/Ruby.framework/Versions/2.6/usr/lib/ruby/2.6.0/rubygems/ext/ext_conf_builder.rb:47:in block in build' /System/Library/Frameworks/Ruby.framework/Versions/2.6/usr/lib/ruby/2.6.0/tempfile.rb:295:inopen' /System/Library/Frameworks/Ruby.framework/Versions/2.6/usr/lib/ruby/2.6.0/rubygems/ext/ext_conf_builder.rb:29:in build' /System/Library/Frameworks/Ruby.framework/Versions/2.6/usr/lib/ruby/2.6.0/rubygems/ext/builder.rb:185:inblock in build_extension' /System/Library/Frameworks/Ruby.framework/Versions/2.6/usr/lib/ruby/2.6.0/monitor.rb:235:in mon_synchronize' /System/Library/Frameworks/Ruby.framework/Versions/2.6/usr/lib/ruby/2.6.0/rubygems/ext/builder.rb:181:inbuild_extension' /System/Library/Frameworks/Ruby.framework/Versions/2.6/usr/lib/ruby/2.6.0/rubygems/ext/builder.rb:229:in block in build_extensions' /System/Library/Frameworks/Ruby.framework/Versions/2.6/usr/lib/ruby/2.6.0/rubygems/ext/builder.rb:226:ineach' /System/Library/Frameworks/Ruby.framework/Versions/2.6/usr/lib/ruby/2.6.0/rubygems/ext/builder.rb:226:in build_extensions' /System/Library/Frameworks/Ruby.framework/Versions/2.6/usr/lib/ruby/2.6.0/rubygems/installer.rb:830:inbuild_extensions' /Users/apple/.gem/ruby/2.6.0/gems/bundler-2.4.12/lib/bundler/rubygems_gem_installer.rb:72:in build_extensions' /Users/apple/.gem/ruby/2.6.0/gems/bundler-2.4.12/lib/bundler/rubygems_gem_installer.rb:28:ininstall' /Users/apple/.gem/ruby/2.6.0/gems/bundler-2.4.12/lib/bundler/source/rubygems.rb:198:in install' /Users/apple/.gem/ruby/2.6.0/gems/bundler-2.4.12/lib/bundler/installer/gem_installer.rb:54:ininstall' /Users/apple/.gem/ruby/2.6.0/gems/bundler-2.4.12/lib/bundler/installer/gem_installer.rb:16:in install_from_spec' /Users/apple/.gem/ruby/2.6.0/gems/bundler-2.4.12/lib/bundler/installer/parallel_installer.rb:156:indo_install' /Users/apple/.gem/ruby/2.6.0/gems/bundler-2.4.12/lib/bundler/installer/parallel_installer.rb:147:in block in worker_pool' /Users/apple/.gem/ruby/2.6.0/gems/bundler-2.4.12/lib/bundler/worker.rb:62:inapply_func' /Users/apple/.gem/ruby/2.6.0/gems/bundler-2.4.12/lib/bundler/worker.rb:57:in block in process_queue' /Users/apple/.gem/ruby/2.6.0/gems/bundler-2.4.12/lib/bundler/worker.rb:54:inloop' /Users/apple/.gem/ruby/2.6.0/gems/bundler-2.4.12/lib/bundler/worker.rb:54:in process_queue' /Users/apple/.gem/ruby/2.6.0/gems/bundler-2.4.12/lib/bundler/worker.rb:90:inblock (2 levels) in create_threads' An error occurred while installing ffi (1.15.5), and Bundler cannot continue. In Gemfile: cocoapods was resolved to 1.12.1, which depends on cocoapods-core was resolved to 1.12.1, which depends on typhoeus was resolved to 1.4.0, which depends on ethon was resolved to 0.16.0, which depends on ffi 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/apple/.npm/_npx/7930a8670f922cdb/node_modules/@react-native-community/cli/build/commands/init/init.js:131:11) at process.processTicksAndRejections (node:internal/process/task_queues:95:5) at async Object.initialize [as func] (/Users/apple/.npm/_npx/7930a8670f922cdb/node_modules/@react-native-community/cli/build/commands/init/init.js:184:3) at async Command.handleAction (/Users/apple/.npm/_npx/7930a8670f922cdb/node_modules/@react-native-community/cli/build/index.js:106:9)`

After this error created a folder with enesial react native codes but does not run at all

Screen Shot 1402-02-18 at 12 39 49

My macbook pro mid 2015

Screen Shot 1402-02-18 at 12 17 54 Screen Shot 1402-02-18 at 12 19 46 Screen Shot 1402-02-18 at 12 20 59 Screen Shot 1402-02-18 at 12 35 40 Screen Shot 1402-02-18 at 12 38 12

React Native Version

0.71 latest version (i run react-native@latest)

Output of npx react-native info

error: unknown command 'info' (Did you mean init?)

Screen Shot 1402-02-18 at 13 31 23

Tried to update rubygem but

Screen Shot 1402-02-18 at 18 59 00

Steps to reproduce

these things make problem cocopods bundle install ruby

Snack, code example, screenshot, or link to a repository

just run simple command in terminal npx react-native@latest init AwesomeProject

github-actions[bot] commented 1 year ago
:warning: Add or Reformat Version Info
:information_source: We could not find or parse the version number of React Native in your issue report. Please use the template, and report your version including major, minor, and patch numbers - e.g. 0.70.2
starterProgrammer commented 1 year ago

Errors when installing cocoapods with gem

Fixed

sudo xcodebuild -license accept ruby -rrbconfig -e 'puts RbConfig::CONFIG["rubyhdrdir"]'

Need to install 'libffi' and 'libffi-dev'

Fixed

install port at first from here sudo port install libffi OR try with brew brew install libffi

Installing xcodeproj 1.22.0 error

Fixed

I had this same error on macOS Monterey 12.6.2 with Xcode 13.4, Xcode 14.0.1 and Xcode 14.2 installed. Changing the default Xcode (Xcode / Preferences / Locations - "Command Line Tools:) from the latest (14.2) to 13.4 and trying again was successful. With 14.2 as the default: sudo gem install cocoapods -v 1.11.2 => #fail sudo gem install cocoapods => #fail (different error message) After changing to 13.4 as the default: sudo gem install cocoapods -v 1.11.2 => success, and pod --version => 1.11.2

Install Gcc

I had this issue today. install GCC prior to executing bundle install

installing ffi 1.15.5 with native extensions building native extensions with: '--enable-system-libffi'

Fixed

bundle config --local build.ffi --with-cflags=-Wno-error=implicit-function-declaration

bundle install

i think we can comment --enable-system-libffi from bundle config file in ~/.bundle/config

237035577-2466f9cd-3e77-4cdf-946c-fefb6e3f42f3
cortinico commented 1 year ago

That's a duplicate of https://github.com/facebook/react-native/issues/37183

starterProgrammer commented 1 year ago

That's a duplicate of #37183 there is not perfect and complete soulution for this issue there...

i fixed this issue but happening again every time i start refresh react native app

starterProgrammer commented 1 year ago

This steps work for me perfectly to create react native project without error

1- npx react-native init testproject --skip-install -—npm 2- cd testproject 3- npm install or yearn install 4- cd ios 5- bundle config --local build.ffi --with-cflags=-Wno-error=implicit-function-declaration 6- bundle install 7- bundle exec pod install