3

I'm trying to install cocoapods so I can install a firebase plugin for my cordova app. I ran sudo gem install cocoapods and the gem was successfully installed. then when I tried to run pod setup it gave me some error, tried googling the solution, one of them was to uninstall cocoapods and run sudo gem update --system. did that, re-installed cocoapods, ran pod setup again, but now i'm getting a different error. this is what my terminal shows me after running pod setup:

Traceback (most recent call last):
10: from /Users/almiraputrisandy/.rvm/gems/ruby-head/bin/ruby_executable_hooks:24:in `<main>'
 9: from /Users/almiraputrisandy/.rvm/gems/ruby-head/bin/ruby_executable_hooks:24:in `eval'
 8: from /Users/almiraputrisandy/.rvm/rubies/ruby-head/bin/pod:23:in `<main>'
 7: from /Users/almiraputrisandy/.rvm/rubies/ruby-head/bin/pod:23:in `load'
 6: from /Users/almiraputrisandy/.rvm/rubies/ruby-head/lib/ruby/gems/2.7.0/gems/cocoapods-1.8.4/bin/pod:36:in `<top (required)>'
 5: from /Users/almiraputrisandy/.rvm/rubies/ruby-head/lib/ruby/site_ruby/2.7.0/rubygems/core_ext/kernel_require.rb:92:in `require'
 4: from /Users/almiraputrisandy/.rvm/rubies/ruby-head/lib/ruby/site_ruby/2.7.0/rubygems/core_ext/kernel_require.rb:92:in `require'
 3: from /Users/almiraputrisandy/.rvm/rubies/ruby-head/lib/ruby/gems/2.7.0/gems/cocoapods-1.8.4/lib/cocoapods.rb:17:in `<top (required)>'
 2: from /Users/almiraputrisandy/.rvm/rubies/ruby-head/lib/ruby/gems/2.7.0/gems/cocoapods-1.8.4/lib/cocoapods.rb:23:in `<module:Pod>'
 1: from /Users/almiraputrisandy/.rvm/rubies/ruby-head/lib/ruby/site_ruby/2.7.0/rubygems/core_ext/kernel_require.rb:92:in `require'
 /Users/almiraputrisandy/.rvm/rubies/ruby-head/lib/ruby/site_ruby/2.7.0/rubygems/core_ext/kernel_require.rb:92:in `require': cannot load such file -- cocoapods-core (LoadError)

I can't seem to find the solution for this, so if anyone knows a solution, please help me! My Macbook's OS is HighSierra 10.13.6. Thank you in advance!

Almira
  • 131
  • 1
  • 8

2 Answers2

5

I have solved my problem by running the following:

$ sudo gem uninstall cocoapods-core cocoapods-downloader cocoapods
$ sudo gem install cocoapods

if you get a LoadError - cannot load such file -- cocoapods_deintegrate error after running pod install after running the 2 commands above, run this command to solve the problem:

$ sudo gem install cocoapods-deintegrate

Thank you to these two answers that helped me:

Almira
  • 131
  • 1
  • 8
2

It appears that Cocoapods doesn't like using Ruby installed via rvm or rbenv. If you're using these version managers for Ruby switch to the system Ruby

For rvm

rvm use system

For rbenv

rbenv global system

You'll probably want to switch back after you're done as system Ruby is terrible for development and if you're using rbenv/rvm you're likely doing Ruby development.

After switching to system Ruby pod setup worked fine for me.

edit: In general doing sudo anything is very bad practice. If you're required to do that your environment is setup wrong and while it may get you past this problem more bigger problems are heading your way.

crempp
  • 248
  • 1
  • 7