编辑:我最初的任务是让 React Native 在我的计算机上运行。然而,我这样做遇到了几个问题。我已将问题根源追溯到我的 ruby 版本,该版本不会更新。
当我跑步时
gem install bundler
我得到以下内容
bundler requires Ruby version >= 3.0.0. The current ruby version is 2.7.1.83.
所以我尝试了
rvm install ruby-3.1.1
这给了我
Error running '__rvm_make -j8',
please read /Users/bekkiantonelli/.rvm/log/1714491493_ruby-3.1.1/make.log
There has been an error while running make. Halting the installation.
所以本质上我的问题是我无法获得正确版本的 ruby。
以下是我的原帖:
我尝试按照以下指示操作:https://reactnative.dev/docs/environment-setup 我正在运行 Sonoma 14.4.1 和带有 M1 芯片的 Mac,XCode 版本 15.2,ruby 版本 2.7.1
当我走到这一步时
bundle install to install Bundler
我收到以下错误:
21: from /Users/bekkiantonelli/.rvm/gems/ruby-2.7.1/bin/ruby_executable_hooks:22:in `<main>'
20: from /Users/bekkiantonelli/.rvm/gems/ruby-2.7.1/bin/ruby_executable_hooks:22:in `eval'
19: from /Users/bekkiantonelli/.rvm/rubies/ruby-2.7.1/bin/bundle:23:in `<main>'
18: from /Users/bekkiantonelli/.rvm/rubies/ruby-2.7.1/bin/bundle:23:in `load'
17: from /Users/bekkiantonelli/.rvm/gems/ruby-2.7.1/gems/bundler-2.2.19/exe/bundle:37:in `<top (required)>'
16: from /Users/bekkiantonelli/.rvm/gems/ruby-2.7.1/gems/bundler-2.2.19/lib/bundler/friendly_errors.rb:130:in `with_friendly_errors'
15: from /Users/bekkiantonelli/.rvm/gems/ruby-2.7.1/gems/bundler-2.2.19/exe/bundle:49:in `block in <top (required)>'
14: from /Users/bekkiantonelli/.rvm/gems/ruby-2.7.1/gems/bundler-2.2.19/lib/bundler/cli.rb:24:in `start'
13: from /Users/bekkiantonelli/.rvm/gems/ruby-2.7.1/gems/bundler-2.2.19/lib/bundler/vendor/thor/lib/thor/base.rb:485:in `start'
12: from /Users/bekkiantonelli/.rvm/gems/ruby-2.7.1/gems/bundler-2.2.19/lib/bundler/cli.rb:30:in `dispatch'
11: from /Users/bekkiantonelli/.rvm/gems/ruby-2.7.1/gems/bundler-2.2.19/lib/bundler/vendor/thor/lib/thor.rb:392:in `dispatch'
10: from /Users/bekkiantonelli/.rvm/gems/ruby-2.7.1/gems/bundler-2.2.19/lib/bundler/vendor/thor/lib/thor/invocation.rb:127:in `invoke_command'
9: from /Users/bekkiantonelli/.rvm/gems/ruby-2.7.1/gems/bundler-2.2.19/lib/bundler/vendor/thor/lib/thor/command.rb:27:in `run'
8: from /Users/bekkiantonelli/.rvm/gems/ruby-2.7.1/gems/bundler-2.2.19/lib/bundler/cli.rb:258:in `install'
7: from /Users/bekkiantonelli/.rvm/gems/ruby-2.7.1/gems/bundler-2.2.19/lib/bundler/settings.rb:133:in `temporary'
6: from /Users/bekkiantonelli/.rvm/gems/ruby-2.7.1/gems/bundler-2.2.19/lib/bundler/cli.rb:259:in `block in install'
5: from /Users/bekkiantonelli/.rvm/gems/ruby-2.7.1/gems/bundler-2.2.19/lib/bundler/cli/install.rb:52:in `run'
4: from /Users/bekkiantonelli/.rvm/rubies/ruby-2.7.1/lib/ruby/2.7.0/rubygems/core_ext/kernel_require.rb:92:in `require'
3: from /Users/bekkiantonelli/.rvm/rubies/ruby-2.7.1/lib/ruby/2.7.0/rubygems/core_ext/kernel_require.rb:92:in `require'
2: from /Users/bekkiantonelli/.rvm/gems/ruby-2.7.1/gems/bundler-2.2.19/lib/bundler/fetcher.rb:6:in `<top (required)>'
1: from /Users/bekkiantonelli/.rvm/rubies/ruby-2.7.1/lib/ruby/2.7.0/rubygems/core_ext/kernel_require.rb:92:in `require'
/Users/bekkiantonelli/.rvm/rubies/ruby-2.7.1/lib/ruby/2.7.0/rubygems/core_ext/kernel_require.rb:92:in `require': dlopen(/Users/bekkiantonelli/.rvm/rubies/ruby-2.7.1/lib/ruby/2.7.0/-darwin22/zlib.bundle, 0x0009): Library not loaded: /opt/homebrew/opt/zlib/lib/libz.1.dylib (LoadError)
Referenced from: <878913C8-6316-3212-A8AD-F9DD9EA034F5> /Users/bekkiantonelli/.rvm/rubies/ruby-2.7.1/lib/ruby/2.7.0/-darwin22/zlib.bundle
Reason: tried: '/opt/homebrew/opt/zlib/lib/libz.1.dylib' (no such file), '/System/Volumes/Preboot/Cryptexes/OS/opt/homebrew/opt/zlib/lib/libz.1.dylib' (no such file), '/opt/homebrew/opt/zlib/lib/libz.1.dylib' (no such file) - /Users/bekkiantonelli/.rvm/rubies/ruby-2.7.1/lib/ruby/2.7.0/-darwin22/zlib.bundle
当我尝试时也值得注意
bundle exec pod install
我得到以下内容
Could not find gem 'cocoapods (>= 1.13, < 1.15)' in rubygems repository https://rubygems.org/ or installed locally.
The source does not contain any versions of 'cocoapods'
Run `bundle install` to install missing gems.
我尝试过重新安装自制软件。
我也尝试过
gem update --system
这给出了
Error loading RubyGems plugin "/Users/bekkiantonelli/.rvm/rubies/ruby-2.7.1/lib/ruby/gems/2.7.0/gems/executable-hooks-1.7.1/lib/rubygems_plugin.rb": dlopen(/Users/bekkiantonelli/.rvm/rubies/ruby-2.7.1/lib/ruby/2.7.0/-darwin22/openssl.bundle, 0x0009): Library not loaded: /opt/homebrew/opt/[email protected]/lib/libssl.1.1.dylib
Referenced from: <F1F803B3-9EF7-3EDD-A626-FE9DC2ABDBA4> /Users/bekkiantonelli/.rvm/rubies/ruby-2.7.1/lib/ruby/2.7.0/-darwin22/openssl.bundle
Reason: tried: '/opt/homebrew/opt/[email protected]/lib/libssl.1.1.dylib' (no such file), '/System/Volumes/Preboot/Cryptexes/OS/opt/homebrew/opt/[email protected]/lib/libssl.1.1.dylib' (no such file), '/opt/homebrew/opt/[email protected]/lib/libssl.1.1.dylib' (no such file) - /Users/bekkiantonelli/.rvm/rubies/ruby-2.7.1/lib/ruby/2.7.0/-darwin22/openssl.bundle (LoadError)
Error loading RubyGems plugin "/Users/bekkiantonelli/.rvm/rubies/ruby-2.7.1/lib/ruby/gems/2.7.0/gems/gem-wrappers-1.4.0/lib/rubygems_plugin.rb": dlopen(/Users/bekkiantonelli/.rvm/rubies/ruby-2.7.1/lib/ruby/2.7.0/-darwin22/openssl.bundle, 0x0009): Library not loaded: /opt/homebrew/opt/[email protected]/lib/libssl.1.1.dylib
Referenced from: <F1F803B3-9EF7-3EDD-A626-FE9DC2ABDBA4> /Users/bekkiantonelli/.rvm/rubies/ruby-2.7.1/lib/ruby/2.7.0/-darwin22/openssl.bundle
Reason: tried: '/opt/homebrew/opt/[email protected]/lib/libssl.1.1.dylib' (no such file), '/System/Volumes/Preboot/Cryptexes/OS/opt/homebrew/opt/[email protected]/lib/libssl.1.1.dylib' (no such file), '/opt/homebrew/opt/[email protected]/lib/libssl.1.1.dylib' (no such file) - /Users/bekkiantonelli/.rvm/rubies/ruby-2.7.1/lib/ruby/2.7.0/-darwin22/openssl.bundle (LoadError)
ERROR: Loading command: update (LoadError)
dlopen(/Users/bekkiantonelli/.rvm/rubies/ruby-2.7.1/lib/ruby/2.7.0/-darwin22/openssl.bundle, 0x0009): Library not loaded: /opt/homebrew/opt/[email protected]/lib/libssl.1.1.dylib
Referenced from: <F1F803B3-9EF7-3EDD-A626-FE9DC2ABDBA4> /Users/bekkiantonelli/.rvm/rubies/ruby-2.7.1/lib/ruby/2.7.0/-darwin22/openssl.bundle
Reason: tried: '/opt/homebrew/opt/[email protected]/lib/libssl.1.1.dylib' (no such file), '/System/Volumes/Preboot/Cryptexes/OS/opt/homebrew/opt/[email protected]/lib/libssl.1.1.dylib' (no such file), '/opt/homebrew/opt/[email protected]/lib/libssl.1.1.dylib' (no such file) - /Users/bekkiantonelli/.rvm/rubies/ruby-2.7.1/lib/ruby/2.7.0/-darwin22/openssl.bundle
ERROR: While executing gem ... (NoMethodError)
undefined method `invoke_with_build_args' for nil:NilClass
我尝试在罗塞塔上使用终端,而不是在罗塞塔上
如有任何帮助,我们将不胜感激!
感谢 @engineersmnky 链接 ruby 更新修复,我专门使用了该行
rvm install ruby-3.3.0 --reconfigure --with-openssl-dir=$(brew --prefix openssl@3)
这让我能够真正更新 Ruby,这才是真正的问题。然后我就可以 cd 进入项目和 ios 并运行
bundle install
bundle exec pod install
并且运行正确