I tried updating cocoapods with "sudo gem install cocoapods" and it is stated that the latest cocoapods has been installed. However, when I run "pod –version", it still shows that the version is at my previous cocoapods version. Any suggestions on how to update to the latest version?
xx@xx-MacBook-Air ios % sudo gem install cocoapods
Password:
Successfully installed cocoapods-1.11.3
Parsing documentation for cocoapods-1.11.3
Done installing documentation for cocoapods after 1 seconds
1 gem installed
xx@xx-MacBook-Air ios % pod setup
Setup completed
xx@xx-MacBook-Air ios % pod --version
1.10.1
I tried to uninstall cocoapods and reinstall it, following this suggestion with the following codes:
xx@xx-MacBook-Air ios % sudo gem uninstall cocoapods
Remove executables:
pod, sandbox-pod
in addition to the gem? [Yn] y
Removing pod
Removing sandbox-pod
Successfully uninstalled cocoapods-1.11.3
xx@xx-MacBook-Air ios % pod --version
1.10.1
xx@x-MacBook-Air ios % sudo gem uninstall cocoapods
Gem 'cocoapods' is not installed
xx@xx-MacBook-Air okepos % sudo gem install cocoapods
Fetching cocoapods-1.11.3.gem
Successfully installed cocoapods-1.11.3
Parsing documentation for cocoapods-1.11.3
Installing ri documentation for cocoapods-1.11.3
Done installing documentation for cocoapods after 2 seconds
1 gem installed
xx@xx-MacBook-Air ios % pod --version
1.10.1
But even after I have uninstalled cocopods, the pod –version still shows the previous version. I tried re-installing the latest version again but the version still shows 1.10.1
2
Answers
Stop right there. The fact that you have to say
sudo
is the problem. This suggests that you are trying to install gems into the System ruby. You must not do that.Use homebrew to install
rbenv
and userbenv
to configure your own global ruby. Use it and no other from now on.Use
which pod
to figure out where it’s installed. Most likely it’s throughbrew
, so you need to do abrew upgrade
to get the latest version. Generally it’s best to install all Ruby tools through the same method: directly, throughbrew
, or using a Ruby manager likervm
.