Cocoa Pods need to completely re-install

不问归期 提交于 2019-12-30 10:53:28

问题


The Background

I am somewhat new to Unix coming from a .NET environment but I know enough now to get me in trouble.

I got an existing code I am working with that uses Cocoapods so I tried to install Cocoapods.

Initially when I installed it it failed saying it requires a newer version of Ruby. To install Ruby I used an installer called rvm. With some effort I got RVM installed and got Ruby Version 2.1.0.

When I go to directory where the app is and i type pod install it responds with pod: command not found. The assumption is that there must be something wrong with the install of cocoa pods. If I try any command to install or uninstall Cocoapods

gem install cocoapods    or gem uninstall cocoa pods

it returns the same response which is:

/Users/aliabidhusain/.rvm/rubies/ruby-2.1.2/lib/ruby/site_ruby/2.1.0/rubygems/core_ext/kernel_gem.rb:59:in `gem': uninitialized constant Gem::LOADED_SPECS_MUTEX (NameError)
from /Users/aliabidhusain/.rvm/rubies/ruby-2.1.2/lib/ruby/site_ruby/2.1.0/rubygems/core_ext/kernel_require.rb:46:in `require'
from /Users/aliabidhusain/.rvm/rubies/ruby-2.1.2/lib/ruby/2.1.0/rubygems.rb:601:in `load_yaml'
from /Users/aliabidhusain/.rvm/rubies/ruby-2.1.2/lib/ruby/site_ruby/2.1.0/rubygems/config_file.rb:328:in `load_file'
from /Users/aliabidhusain/.rvm/rubies/ruby-2.1.2/lib/ruby/site_ruby/2.1.0/rubygems/config_file.rb:197:in `initialize'
from /Users/aliabidhusain/.rvm/rubies/ruby-2.1.2/lib/ruby/site_ruby/2.1.0/rubygems/gem_runner.rb:74:in `new'
from /Users/aliabidhusain/.rvm/rubies/ruby-2.1.2/lib/ruby/site_ruby/2.1.0/rubygems/gem_runner.rb:74:in `do_configuration'
from /Users/aliabidhusain/.rvm/rubies/ruby-2.1.2/lib/ruby/site_ruby/2.1.0/rubygems/gem_runner.rb:39:in `run'
from /Users/aliabidhusain/.rvm/rubies/ruby-2.1.2/bin/gem:21:in `<main>'

I am thinking that perhaps the failed attempts to install cocoa pods may have either corrupted something, put something in the wrong place. I want to completely uninstall cocoapods and reinstall it but install and uninstall are not doing anything.

UPDATE: Using gem list --local | grep cocoa pods just to see what version of CocoaPods I have installed gives me the same exact output.

The Question:

Does anyone know a way to either fix this issue or completely rip and rebuild CocoaPods?


回答1:


gem env will tell you the installation path of your gems.

By the error you got on the first time you installed the gem it could be a PATH error. Maybe your gems folder is not properly set in the PATH and shell is not finding Cocoapods.

Try to print your PATH with echo $PATH and see if the - EXECUTABLE DIRECTORY: from gem env is there.

Also try gem pristine --all

If that doesn't work try to change to ruby 2.1.2 and reinstall cocoapods.




回答2:


I was brilliantly assisted with help from @Pedros (the currently accepted answer) but because there were so many comments back and forth I decided to clean up the answer that worked for me. I will keep his as the accepted answer since he really helped me tremendously on this one. If this is helpful to you and you choose to up vote, please also up vote the accepted answer since this is derived almost completely from his answer.

Here is what I found out : In my case it was that RVM was not installed correctly so RubyGems wasn't installed correctly. That in turn made CocoaPods not install correctly.

To completely uninstall and remove RVM: try sudo rvm implode or you can do sudo rm -rf ~/.rvm

I did some checks to see if I had the correct versions. I will post what they should be right now but this can be different as versions keep getting updated.

ruby --version should be 2.1.2

which ruby should be the RVM ruby. (To see if there is no conflict with OSX`s ruby)

gem --version should be 2.2.2

Reinstall RVM by doing this: \curl -sSL https://get.rvm.io | bash -s stable --ruby

Reinstall CocoaPods like this: gem install cocoapods

I hope this saves someone some development hours and hair loss :)



来源:https://stackoverflow.com/questions/25016382/cocoa-pods-need-to-completely-re-install

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!