-1

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

scott lee
  • 546
  • 5
  • 23
  • 2
    Use `which pod` to figure out where it's installed. Most likely it's through `brew`, so you need to do a `brew upgrade` to get the latest version. Generally it's best to install all Ruby tools through the same method: directly, through `brew`, or using a Ruby manager like `rvm`. – Jon Shier May 17 '22 at 02:09
  • Thanks for the reply. Ok, let me give it a try. – scott lee May 17 '22 at 02:25
  • Hi @JonShier, you were right. I installed under brew. I use brew upgrade cocoapods and it updated successfully. Thank you for your help – scott lee May 17 '22 at 02:49
  • If you want, you can put suggest that as the answer, I'll give you the credit. Thanks – scott lee May 17 '22 at 02:51

2 Answers2

4

Use which pod to figure out where it's installed. Most likely it's through brew, so you need to do a brew upgrade to get the latest version. Generally it's best to install all Ruby tools through the same method: directly, through brew, or using a Ruby manager like rvm.

Jon Shier
  • 12,200
  • 3
  • 35
  • 37
0
   sudo gem install cocoapods

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 use rbenv to configure your own global ruby. Use it and no other from now on.

matt
  • 515,959
  • 87
  • 875
  • 1,141
  • See my https://www.biteinteractive.com/how-to-get-started-with-pods/ – matt May 17 '22 at 02:40
  • Hi @matt, thanks for the reply. Yes, I realised I used homebrew to install cocoapods initially. Using brew upgrade cocoapods did the trick. Thanks. – scott lee May 17 '22 at 02:53
  • That's insufficient. If you say `which ruby` and you get the system ruby, you're still in trouble. – matt May 17 '22 at 03:04
  • Hmm, when i say `which ruby`, i do get `/usr/bin/ruby`. I'm quite unfamiliar to this. Could you kindly let me know the implications of that? Or how should I go about solving this? Should i just use homebrew to install rbenv and rbenv to configure the global ruby? – scott lee May 17 '22 at 03:10
  • That's what I'm suggesting. I gave you a link to what I think you should do and how to do it. You don't have to, yet, but eventually the system Ruby will probably go away, as the system Python just did, and you really shouldn't be installing any gems into it either. – matt May 17 '22 at 04:14
  • Ok thank you for your help @matt. Appreciate it. – scott lee May 17 '22 at 07:35
  • This is correct however so many other tools' instructions tell you to use sudo, so depressing – funkybro Sep 23 '22 at 15:21