当我尝试在Xcode项目目录中执行pod init
时,它将返回以下内容:
Traceback (most recent call last):
35: from /usr/local/bin/pod:23:in `<main>'
34: from /usr/local/bin/pod:23:in `load'
33: from /Library/Ruby/Gems/2.6.0/gems/cocoapods-1.9.2/bin/pod:36:in `<top (required)>'
32: from /System/Library/Frameworks/Ruby.framework/Versions/2.6/usr/lib/ruby/2.6.0/rubygems/core_ext/kernel_require.rb:54:in `require'
31: from /System/Library/Frameworks/Ruby.framework/Versions/2.6/usr/lib/ruby/2.6.0/rubygems/core_ext/kernel_require.rb:54:in `require'
30: from /Library/Ruby/Gems/2.6.0/gems/cocoapods-1.9.2/lib/cocoapods.rb:8:in `<top (required)>'
29: from /System/Library/Frameworks/Ruby.framework/Versions/2.6/usr/lib/ruby/2.6.0/rubygems/core_ext/kernel_require.rb:54:in `require'
28: from /System/Library/Frameworks/Ruby.framework/Versions/2.6/usr/lib/ruby/2.6.0/rubygems/core_ext/kernel_require.rb:54:in `require'
27: from /Library/Ruby/Gems/2.6.0/gems/activesupport-4.2.11.3/lib/active_support/core_ext/string/inflections.rb:1:in `<top (required)>'
26: from /System/Library/Frameworks/Ruby.framework/Versions/2.6/usr/lib/ruby/2.6.0/rubygems/core_ext/kernel_require.rb:54:in `require'
25: from /System/Library/Frameworks/Ruby.framework/Versions/2.6/usr/lib/ruby/2.6.0/rubygems/core_ext/kernel_require.rb:54:in `require'
24: from /Library/Ruby/Gems/2.6.0/gems/activesupport-4.2.11.3/lib/active_support/inflector/methods.rb:3:in `<top (required)>'
23: from /System/Library/Frameworks/Ruby.framework/Versions/2.6/usr/lib/ruby/2.6.0/rubygems/core_ext/kernel_require.rb:54:in `require'
22: from /System/Library/Frameworks/Ruby.framework/Versions/2.6/usr/lib/ruby/2.6.0/rubygems/core_ext/kernel_require.rb:54:in `require'
21: from /Library/Ruby/Gems/2.6.0/gems/activesupport-4.2.11.3/lib/active_support/inflections.rb:1:in `<top (required)>'
20: from /System/Library/Frameworks/Ruby.framework/Versions/2.6/usr/lib/ruby/2.6.0/rubygems/core_ext/kernel_require.rb:54:in `require'
19: from /System/Library/Frameworks/Ruby.framework/Versions/2.6/usr/lib/ruby/2.6.0/rubygems/core_ext/kernel_require.rb:54:in `require'
18: from /Library/Ruby/Gems/2.6.0/gems/activesupport-4.2.11.3/lib/active_support/inflector/inflections.rb:3:in `<top (required)>'
17: from /System/Library/Frameworks/Ruby.framework/Versions/2.6/usr/lib/ruby/2.6.0/rubygems/core_ext/kernel_require.rb:54:in `require'
16: from /System/Library/Frameworks/Ruby.framework/Versions/2.6/usr/lib/ruby/2.6.0/rubygems/core_ext/kernel_require.rb:54:in `require'
15: from /Library/Ruby/Gems/2.6.0/gems/activesupport-4.2.11.3/lib/active_support/i18n.rb:5:in `<top (required)>'
14: from /System/Library/Frameworks/Ruby.framework/Versions/2.6/usr/lib/ruby/2.6.0/rubygems/core_ext/kernel_require.rb:54:in `require'
13: from /System/Library/Frameworks/Ruby.framework/Versions/2.6/usr/lib/ruby/2.6.0/rubygems/core_ext/kernel_require.rb:54:in `require'
12: from /Library/Ruby/Gems/2.6.0/gems/i18n-0.9.5/lib/i18n.rb:1:in `<top (required)>'
11: from /System/Library/Frameworks/Ruby.framework/Versions/2.6/usr/lib/ruby/2.6.0/rubygems/core_ext/kernel_require.rb:54:in `require'
10: from /System/Library/Frameworks/Ruby.framework/Versions/2.6/usr/lib/ruby/2.6.0/rubygems/core_ext/kernel_require.rb:54:in `require'
9: from /Library/Ruby/Gems/2.6.0/gems/concurrent-ruby-1.1.6/lib/concurrent-ruby/concurrent/map.rb:3:in `<top (required)>'
8: from /System/Library/Frameworks/Ruby.framework/Versions/2.6/usr/lib/ruby/2.6.0/rubygems/core_ext/kernel_require.rb:54:in `require'
7: from /System/Library/Frameworks/Ruby.framework/Versions/2.6/usr/lib/ruby/2.6.0/rubygems/core_ext/kernel_require.rb:54:in `require'
6: from /Library/Ruby/Gems/2.6.0/gems/concurrent-ruby-1.1.6/lib/concurrent-ruby/concurrent/synchronization.rb:5:in `<top (required)>'
5: from /Library/Ruby/Gems/2.6.0/gems/concurrent-ruby-1.1.6/lib/concurrent-ruby/concurrent/utility/native_extension_loader.rb:30:in `load_native_extensions'
4: from /Library/Ruby/Gems/2.6.0/gems/concurrent-ruby-1.1.6/lib/concurrent-ruby/concurrent/utility/native_extension_loader.rb:30:in `each'
3: from /Library/Ruby/Gems/2.6.0/gems/concurrent-ruby-1.1.6/lib/concurrent-ruby/concurrent/utility/native_extension_loader.rb:30:in `block in load_native_extensions'
2: from /Library/Ruby/Gems/2.6.0/gems/concurrent-ruby-1.1.6/lib/concurrent-ruby/concurrent/utility/native_extension_loader.rb:62:in `try_load_c_extension'
1: from /System/Library/Frameworks/Ruby.framework/Versions/2.6/usr/lib/ruby/2.6.0/rubygems/core_ext/kernel_require.rb:54:in `require'
/System/Library/Frameworks/Ruby.framework/Versions/2.6/usr/lib/ruby/2.6.0/rubygems/core_ext/kernel_require.rb:54:in `require': cannot load such file -- concurrent/concurrent_ruby_ext (LoadError)
46: from /usr/local/bin/pod:23:in `<main>'
45: from /usr/local/bin/pod:23:in `load'
44: from /Library/Ruby/Gems/2.6.0/gems/cocoapods-1.9.2/bin/pod:36:in `<top (required)>'
43: from /System/Library/Frameworks/Ruby.framework/Versions/2.6/usr/lib/ruby/2.6.0/rubygems/core_ext/kernel_require.rb:54:in `require'
42: from /System/Library/Frameworks/Ruby.framework/Versions/2.6/usr/lib/ruby/2.6.0/rubygems/core_ext/kernel_require.rb:54:in `require'
41: from /Library/Ruby/Gems/2.6.0/gems/cocoapods-1.9.2/lib/cocoapods.rb:8:in `<top (required)>'
40: from /System/Library/Frameworks/Ruby.framework/Versions/2.6/usr/lib/ruby/2.6.0/rubygems/core_ext/kernel_require.rb:54:in `require'
39: from /System/Library/Frameworks/Ruby.framework/Versions/2.6/usr/lib/ruby/2.6.0/rubygems/core_ext/kernel_require.rb:54:in `require'
38: from /Library/Ruby/Gems/2.6.0/gems/activesupport-4.2.11.3/lib/active_support/core_ext/string/inflections.rb:1:in `<top (required)>'
37: from /System/Library/Frameworks/Ruby.framework/Versions/2.6/usr/lib/ruby/2.6.0/rubygems/core_ext/kernel_require.rb:54:in `require'
36: from /System/Library/Frameworks/Ruby.framework/Versions/2.6/usr/lib/ruby/2.6.0/rubygems/core_ext/kernel_require.rb:54:in `require'
35: from /Library/Ruby/Gems/2.6.0/gems/activesupport-4.2.11.3/lib/active_support/inflector/methods.rb:3:in `<top (required)>'
34: from /System/Library/Frameworks/Ruby.framework/Versions/2.6/usr/lib/ruby/2.6.0/rubygems/core_ext/kernel_require.rb:54:in `require'
33: from /System/Library/Frameworks/Ruby.framework/Versions/2.6/usr/lib/ruby/2.6.0/rubygems/core_ext/kernel_require.rb:54:in `require'
32: from /Library/Ruby/Gems/2.6.0/gems/activesupport-4.2.11.3/lib/active_support/inflections.rb:1:in `<top (required)>'
31: from /System/Library/Frameworks/Ruby.framework/Versions/2.6/usr/lib/ruby/2.6.0/rubygems/core_ext/kernel_require.rb:54:in `require'
30: from /System/Library/Frameworks/Ruby.framework/Versions/2.6/usr/lib/ruby/2.6.0/rubygems/core_ext/kernel_require.rb:54:in `require'
29: from /Library/Ruby/Gems/2.6.0/gems/activesupport-4.2.11.3/lib/active_support/inflector/inflections.rb:3:in `<top (required)>'
28: from /System/Library/Frameworks/Ruby.framework/Versions/2.6/usr/lib/ruby/2.6.0/rubygems/core_ext/kernel_require.rb:54:in `require'
27: from /System/Library/Frameworks/Ruby.framework/Versions/2.6/usr/lib/ruby/2.6.0/rubygems/core_ext/kernel_require.rb:54:in `require'
26: from /Library/Ruby/Gems/2.6.0/gems/activesupport-4.2.11.3/lib/active_support/i18n.rb:5:in `<top (required)>'
25: from /System/Library/Frameworks/Ruby.framework/Versions/2.6/usr/lib/ruby/2.6.0/rubygems/core_ext/kernel_require.rb:54:in `require'
24: from /System/Library/Frameworks/Ruby.framework/Versions/2.6/usr/lib/ruby/2.6.0/rubygems/core_ext/kernel_require.rb:54:in `require'
23: from /Library/Ruby/Gems/2.6.0/gems/i18n-0.9.5/lib/i18n.rb:1:in `<top (required)>'
22: from /System/Library/Frameworks/Ruby.framework/Versions/2.6/usr/lib/ruby/2.6.0/rubygems/core_ext/kernel_require.rb:54:in `require'
21: from /System/Library/Frameworks/Ruby.framework/Versions/2.6/usr/lib/ruby/2.6.0/rubygems/core_ext/kernel_require.rb:54:in `require'
20: from /Library/Ruby/Gems/2.6.0/gems/concurrent-ruby-1.1.6/lib/concurrent-ruby/concurrent/map.rb:3:in `<top (required)>'
19: from /System/Library/Frameworks/Ruby.framework/Versions/2.6/usr/lib/ruby/2.6.0/rubygems/core_ext/kernel_require.rb:54:in `require'
18: from /System/Library/Frameworks/Ruby.framework/Versions/2.6/usr/lib/ruby/2.6.0/rubygems/core_ext/kernel_require.rb:54:in `require'
17: from /Library/Ruby/Gems/2.6.0/gems/concurrent-ruby-1.1.6/lib/concurrent-ruby/concurrent/synchronization.rb:5:in `<top (required)>'
16: from /Library/Ruby/Gems/2.6.0/gems/concurrent-ruby-1.1.6/lib/concurrent-ruby/concurrent/utility/native_extension_loader.rb:30:in `load_native_extensions'
15: from /Library/Ruby/Gems/2.6.0/gems/concurrent-ruby-1.1.6/lib/concurrent-ruby/concurrent/utility/native_extension_loader.rb:30:in `each'
14: from /Library/Ruby/Gems/2.6.0/gems/concurrent-ruby-1.1.6/lib/concurrent-ruby/concurrent/utility/native_extension_loader.rb:30:in `block in load_native_extensions'
13: from /Library/Ruby/Gems/2.6.0/gems/concurrent-ruby-1.1.6/lib/concurrent-ruby/concurrent/utility/native_extension_loader.rb:62:in `try_load_c_extension'
12: from /System/Library/Frameworks/Ruby.framework/Versions/2.6/usr/lib/ruby/2.6.0/rubygems/core_ext/kernel_require.rb:34:in `require'
11: from /System/Library/Frameworks/Ruby.framework/Versions/2.6/usr/lib/ruby/2.6.0/rubygems/core_ext/kernel_require.rb:123:in `rescue in require'
10: from /System/Library/Frameworks/Ruby.framework/Versions/2.6/usr/lib/ruby/2.6.0/rubygems.rb:212:in `try_activate'
9: from /System/Library/Frameworks/Ruby.framework/Versions/2.6/usr/lib/ruby/2.6.0/rubygems/specification.rb:1041:in `find_by_path'
8: from /System/Library/Frameworks/Ruby.framework/Versions/2.6/usr/lib/ruby/2.6.0/rubygems/specification.rb:1041:in `find'
7: from /System/Library/Frameworks/Ruby.framework/Versions/2.6/usr/lib/ruby/2.6.0/rubygems/specification.rb:1041:in `each'
6: from /System/Library/Frameworks/Ruby.framework/Versions/2.6/usr/lib/ruby/2.6.0/rubygems/specification.rb:1042:in `block in find_by_path'
5: from /System/Library/Frameworks/Ruby.framework/Versions/2.6/usr/lib/ruby/2.6.0/rubygems/bundler_version_finder.rb:39:in `compatible?'
4: from /System/Library/Frameworks/Ruby.framework/Versions/2.6/usr/lib/ruby/2.6.0/rubygems/bundler_version_finder.rb:7:in `bundler_version'
3: from /System/Library/Frameworks/Ruby.framework/Versions/2.6/usr/lib/ruby/2.6.0/rubygems/bundler_version_finder.rb:22:in `bundler_version_with_reason'
2: from /System/Library/Frameworks/Ruby.framework/Versions/2.6/usr/lib/ruby/2.6.0/rubygems/bundler_version_finder.rb:68:in `lockfile_version'
1: from /System/Library/Frameworks/Ruby.framework/Versions/2.6/usr/lib/ruby/2.6.0/rubygems/bundler_version_finder.rb:80:in `lockfile_contents'
/System/Library/Frameworks/Ruby.framework/Versions/2.6/usr/lib/ruby/2.6.0/rubygems/bundler_version_finder.rb:80:in `pwd': Operation not permitted - getcwd (Errno::EPERM)
我已经安装了Homebrew
,Ruby
和Cocoapods
。我正在运行macOS Catalina 10.15.4
和Xcode 11.3.1
。
我尝试遵循this advice并通过以下命令在/usr/local/bin
中安装可可足类:sudo gem install -n /usr/local/bin cocoapods
但是在安装它时出现了相同的错误:Operation not permitted - getcwd (Errno::EPERM)
知道什么问题吗?
编辑
重新安装Ruby管理器以安装Ruby后,出现新错误:
2: from /Users/zorgan/.rvm/gems/ruby-2.6.5/bin/ruby_executable_hooks:9:in `<main>'
1: from /Users/zorgan/.rvm/rubies/ruby-2.6.5/lib/ruby/site_ruby/2.6.0/rubygems/core_ext/kernel_require.rb:54:in `require'
/Users/zorgan/.rvm/rubies/ruby-2.6.5/lib/ruby/site_ruby/2.6.0/rubygems/core_ext/kernel_require.rb:54:in `require': cannot load such file -- executable-hooks/hooks (LoadError)
13: from /Users/zorgan/.rvm/gems/ruby-2.6.5/bin/ruby_executable_hooks:9:in `<main>'
12: from /Users/zorgan/.rvm/rubies/ruby-2.6.5/lib/ruby/site_ruby/2.6.0/rubygems/core_ext/kernel_require.rb:34:in `require'
11: from /Users/zorgan/.rvm/rubies/ruby-2.6.5/lib/ruby/site_ruby/2.6.0/rubygems/core_ext/kernel_require.rb:123:in `rescue in require'
10: from /Users/zorgan/.rvm/rubies/ruby-2.6.5/lib/ruby/site_ruby/2.6.0/rubygems.rb:213:in `try_activate'
9: from /Users/zorgan/.rvm/rubies/ruby-2.6.5/lib/ruby/site_ruby/2.6.0/rubygems/specification.rb:1036:in `find_by_path'
8: from /Users/zorgan/.rvm/rubies/ruby-2.6.5/lib/ruby/site_ruby/2.6.0/rubygems/specification.rb:1036:in `find'
7: from /Users/zorgan/.rvm/rubies/ruby-2.6.5/lib/ruby/site_ruby/2.6.0/rubygems/specification.rb:1036:in `each'
6: from /Users/zorgan/.rvm/rubies/ruby-2.6.5/lib/ruby/site_ruby/2.6.0/rubygems/specification.rb:1037:in `block in find_by_path'
5: from /Users/zorgan/.rvm/rubies/ruby-2.6.5/lib/ruby/site_ruby/2.6.0/rubygems/bundler_version_finder.rb:39:in `compatible?'
4: from /Users/zorgan/.rvm/rubies/ruby-2.6.5/lib/ruby/site_ruby/2.6.0/rubygems/bundler_version_finder.rb:7:in `bundler_version'
3: from /Users/zorgan/.rvm/rubies/ruby-2.6.5/lib/ruby/site_ruby/2.6.0/rubygems/bundler_version_finder.rb:22:in `bundler_version_with_reason'
2: from /Users/zorgan/.rvm/rubies/ruby-2.6.5/lib/ruby/site_ruby/2.6.0/rubygems/bundler_version_finder.rb:68:in `lockfile_version'
1: from /Users/zorgan/.rvm/rubies/ruby-2.6.5/lib/ruby/site_ruby/2.6.0/rubygems/bundler_version_finder.rb:80:in `lockfile_contents'
/Users/zorgan/.rvm/rubies/ruby-2.6.5/lib/ruby/site_ruby/2.6.0/rubygems/bundler_version_finder.rb:80:in `pwd': Operation not permitted - getcwd (Errno::EPERM)
答案 0 :(得分:2)
如以下注释中所述,这是通过将项目移出~/Library
来解决的,因为这是macOS上的特殊系统目录,并且可以触发上述错误。即便如此,使用Ruby管理器的建议仍是最佳实践:
您在使用macOS沙箱权限时遇到了问题。最简单的解决方法是不使用macOS随附的内置Ruby版本,而是使用Ruby管理器来安装Ruby:
\curl -sSL https://get.rvm.io | bash -s stable
rvm install 2.6
sudo
):gem install cocoapods
which pod
的输出类似于:/Users/foo/.rvm/gems/ruby-2.6.3/bin/pod
然后重试您的pod init
命令。
以下一些资源说明了为什么不使用系统的默认Ruby版本:
如果您愿意,还可以安装和使用其他管理器:
每种方法都有其优点和缺点,但是经过7年的专业Ruby开发,RVM从未使我犯错,因此,我建议这样做。