Background
A few years ago I installed cocoapods for a project I was working on. Since then I have not used it and now I need to update it to get Flutter working.
System
OS MacOS Mojave
Version 10.14.3
Question
I do not want to end up installing 2 different versions of cocoapods and cause myself a bunch of problems. I am trying to determine how I originally installed cocoapods so I can update it.
How can I determine how cocoapods was originally installed?
What I Tried
I can see cocoapods is installed because when I run,
pod --version the output is
1.3.1
When I run which cocoapods I get
cocoapods not found
When I run which pod I get
/usr/local/bin/pod
I checked that file and it is a cocoapods file installed by a ruby gem. This is what I see when I look at the file,
!/System/Library/Frameworks/Ruby.framework/Versions/2.3/usr/bin/ruby
#
This file was generated by RubyGems.
#
The application 'cocoapods' is installed as part of a gem, and
this file is here to facilitate running it.
At this point I try and update it,
gem update cocoapods
I get,
Updating installed gems Nothing to update
When I run gem list I get a list of installed gems but pods nor cocoapods is in the list.
I also checked brew list and do not see it installed in there either. I can see evidence that it was installed as a gem but I do not understand why gem update cocoapods finds nothing to update.
Update
I broke down and went ahead and tried to install cocoapods as a gem since I already had the gem file in place.
gem install cocoapods
When I run gem list it shows that cocoapods was installed as version 1.6.1 as there are a bunch of new cocoapods files in my gem list.
When I run pod --version it still says 1.3.1.
I removed the pod file from /usr/local/bin and then ran pod --version again. At this point I get a command not found error.
After adding it back I can see the same output of the old version exists again. 1.3.1.
I tried removing the old pod file from /usr/local/bin and then gem install cocoapods. After doing so the pod command will not work but I can see that cocoapods is installed as a gem on my system.
Evidently there is a problem installing cocoapods on some newer MacOS systems due to the all of the permissions changes rolled out from Apple.
I saw a suggestion to install cocoapods on El Captain like this,
sudo gem install -n /usr/local/bin cocoapods
Which would explain why I have a rogue pod file inside of that directory.
Solution
I deleted the pod file out of my /usr/local/bin folder.
I installed cocoapods again using => sudo gem install -n /usr/local/bin cocoapods
Now when I run pod --version I get 1.6.1.
Related
I just start a react-native project. However, this question had me for a day.
I tried all possible way to solve it. For example,
sudo gem uninstall cocoapods
rvm uninstall
brew install cocoapods
However, there is no luck for me.
I would like to point out that I can pod --version under other path but issue occur when I try to pod under my project path. I also tried to set rvm default version to 2.7.5 but issue still happen.
Also, I am not using Apple M1
Traceback (most recent call last):
4: from /Users/nicholas/.rvm/gems/ruby-2.7.5/bin/ruby_executable_hooks:22:in `<main>'
3: from /Users/nicholas/.rvm/gems/ruby-2.7.5/bin/ruby_executable_hooks:22:in `eval'
2: from /Users/nicholas/.rvm/gems/ruby-2.7.5/bin/pod:23:in `<main>'
1: from /Users/nicholas/.rvm/rubies/ruby-2.7.5/lib/ruby/2.7.0/rubygems.rb:296:in `activate_bin_path'
/Users/nicholas/.rvm/rubies/ruby-2.7.5/lib/ruby/2.7.0/rubygems.rb:277:in `find_spec_for_exe': can't find gem cocoapods (>= 0.a) with executable pod (Gem::GemNotFoundException)
Try running bundle install in the root of your project. Then either go to ios and run pod install or use npx pod-install from the project root.
This issue is due to the difference in your default ruby version and ruby version specified in Gemfile . To install multiple ruby version you have to install rvm on your system and then install multiple rub versions. after install the ruby version specified in you gem file. you have to run the bundle install command . link
bundle install is a command we use to install the dependencies specified in your Gemfile.
Gemfile
Simply put, Gemfile is a format for describing gem dependencies for Ruby programs. Or you can say it contains the gems you need in this project.
After this you can install run npx pod-install or cd ios and pod install
Bundle install prior to pod install works.
To answer Bundle Install, what happens is, when generating react native project the configuration is set to default mac gem version. If you have updated gem version on your mac the project configuration could not pick the correct gem version. thats why it throws the can't find gem cocoapods.
by doing Bundle install, It will update the project config according to the mac gem version.
Remove cocoapods:
sudo gem uninstall cocoapods
Then instal again:
sudo gem install -n /usr/local/bin cocoapods
When I installed cocoa pods I got this message. The cocoa pods downloaded is in version 1.10.1. Ive tried to use the command they give but this appears:
Ignoring ffi-1.13.1 because its extensions are not built. Try: gem pristine ffi --version 1.13.1
ERROR: While executing gem ... (Gem::FilePermissionError)
You don't have write permissions for the /Library/Ruby/Gems/2.6.0 directory.
Does it means that the latest version available is 1.13.1 but I can't use it because of a problem? How to solve it?
This solved the issue for me
brew install cocoapods
should already be linked (as pointed out by Raphael Pinel) but if you want to make sure run
brew link --overwrite cocoapods
Basically, you need to do what the warning message says: install the Gem "ffi" in the specified version by running gem pristine ffi --version 1.13.1. However, usually you don't have write permissions on the system to install a Gem into the stated directory.
You could probably just use sudo, i.e. run the command sudo gem pristine ffi --version 1.13.1 and enter the password, but I guess this is generally not recommended as it is a security risk.
I installed it like this:
gem install ffi --version 1.13.1 --user-install
Then I had to add the installation path to my PATH variable; in my case I added this line to my ~/.zshrc:
export PATH=$HOME/.gem/ruby/2.6.0/bin:$PATH
I'm really not an expert on Ruby stuff, but this solved the issue for me.
This worked for me :
sudo gem pristine ffi (don't write a version here, because it will fix the problem of all versions)
then :
pod install
MacOS: Ventura v13.0
Updating the Ruby version worked like a charm. Did the following steps.
$ brew install rbenv
Installed the latest ruby version.
$ rbenv install 3.1.2
To activate the above version as global default version.
$rbenv global 3.1.2
To install ffi
$ sudo gem install ffi --version 1.15.5 --user-install
in my case ( mbpm1 pro ) , my other project are fine , but some project from my friend ( windows only) i got some issue , i fixed by
arch -x86_64 sudo gem install ffi
flutter clean dont forget to clean after installing some gem
flutter pub get re get
run now ( these run would automatically run pod install ) just click on main.dart ( vscode )
None of the answers worked for me. So, I thought of uninstalling all versions of ruby which I had unknowingly installed, and keeping only the one installed by Xcode.
brew uninstall --force ruby
Then, uninstalled cocoapods
brew uninstall --force cocoapods
I was left with the ruby installed by XCode. I ran:
gem pristine ffi --version 1.15.3
I realised the other versions got installed in ~/.local
I deleted the whole folder as it had nothing other than the old gem folder
rm -rf ~/.local
Now, reinstall cocoapods:
brew install cocoapods
Try running:
pod install
OR
gem -v
You should not see this error.
This usually happens when you have multiple gem versions installed and the path is incorrect.
P.S I am using macOS Monterey 12.1
My issue was that the pre installed ruby had those extensions installed and caused the error messages. Run the command below to
see all installed packages. Said command should also print the error Ignoring ... because its extensions are not built. Directly reference /usr/bin/gem since you might have ruby installed via brew which would be called otherwise.
/usr/bin/gem list
Then manually uninstall all mentioned extensions for the default ruby.
sudo /usr/bin/gem uninstall ffi
In my case I had paths mismatch, this command helped me:
rvm get stable --auto-dotfiles
Also check paths order in you .zshrc file
f.e.
# Ruby
export PATH="~/.rvm/gems/ruby-2.6.0/bin:$PATH"
export PATH="/usr/local/opt/ruby/bin:$PATH"
export LDFLAGS="-L/usr/local/opt/ruby/lib"
export CPPFLAGS="-I/usr/local/opt/ruby/include"
export PKG_CONFIG_PATH="/usr/local/opt/ruby/lib/pkgconfig"
# User local
export PATH="/usr/local/bin:$PATH"
gem install cocoapods
This is a workaround and not a solution, but for me, after trying all other posted solutions (on Monterey 13.0.1, I traced it back to it seemingly picking the homebrew installed cocoapods picking up the ffi library from ~/.rbenv/shims, with the only timely work around being to install cocoapods via gem, per above.
All this said, I don't claim to be well versed in rbenv, or any other dependency manager, for that matter.
I'd love to know a better answer that didn't bork the homebrew based installation.
Start the Terminal on a Mac M1 with Rosetta and run
pod update
After moving to Mac OS Sierra, I'm facing problem to install cocoapods.
Every time I run sudo gem install cocoapods --pre every thing installed well, but while trying to install a pod, the terminal stack on Setting up CocoaPods master repo. Already updated the system with sudo gem update --system and still got the same issue, searched online to found old answers to use pod install --verbose Ss. I found in THIS answer fail again tells to install it manually.
NOTE: I have the latest version of 'Command Line Tools'. Any suggestion or how to install master repo manually?
Even when empty pod (i.e. without any pod name in it) is installed it gives
/Library/Ruby/Site/2.0.0/rubygems/dependency.rb:315:in `to_specs': Could not find 'cocoapods' (>= 0) among 66 total gem(s) (Gem::LoadError)
Checked in 'GEM_PATH=/Users/my_name/.gem/ruby/2.0.0:/Library/Ruby/Gems/2.0.0:/System/Library/Frameworks/Ruby.framework/Versions/2.0/usr/lib/ruby/gems/2.0.0', execute `gem env` for more information
from /Library/Ruby/Site/2.0.0/rubygems/dependency.rb:324:in `to_spec'
from /Library/Ruby/Site/2.0.0/rubygems/core_ext/kernel_gem.rb:64:in `gem'
from /usr/local/bin/pod:22:in `'
Follow the instruction given below. It may help you.
check pod version using command given below
pod --version
if there is any version installed remove it by using the command
sudo gem uninstall cocoapods
restart your mac and reinstall again using the command
sudo gem install -n /usr/local/bin cocoapods
it will be security problem with mac os Sierra, i will try it and it will work for me . u can try it.
unable to load gem cocoa pods while creating repo
I had some problems with one version of the project. I've found this answer where someone suggest steps to remove all cocoapods-connected stuff from the machine and reinstall it. I did follow the steps:
$ 'pod --version'
0.36.1
$ gem list --local | grep cocoapods
cocoapods (0.39.0.rc.1, 0.38.2, 0.38.1, 0.37.2)
cocoapods-core (0.39.0.rc.1, 0.38.2, 0.38.1, 0.37.2)
cocoapods-downloader (0.9.3, 0.9.1)
cocoapods-plugins (0.4.2)
cocoapods-search (0.1.0)
cocoapods-stats (0.6.2, 0.5.3)
cocoapods-trunk (0.6.4, 0.6.1)
cocoapods-try (0.5.1, 0.4.5)
$ gem uninstall cocoapods // and all others from the list above
The problem is that when i again grep all cocoapods, the list was equal to upper one, nothing disappeared.
$ sudo gem uninstall cocoapods
Select gem to uninstall:
1. cocoapods-0.37.2
2. cocoapods-0.38.1
3. cocoapods-0.38.2
4. cocoapods-0.39.0.rc.1
5. All versions
> 5
$ pod --version
// here was the error command not found, so everything fine
$ sudo gem install cocoapods
Fetching: cocoapods-0.38.2.gem (100%)
Successfully installed cocoapods-0.38.2
Parsing documentation for cocoapods-0.38.2
Installing ri documentation for cocoapods-0.38.2
Done installing documentation for cocoapods after 2 seconds
1 gem installed
$ pod --version
Could not find proper version of cocoapods (0.36.1) in any of the sources
Run `bundle install` to install missing gems.
But why does it want me to install 0.36.1? Anyway, as it asked, I did:
$bundle install
Installing cocoapods-core 0.36.1
Installing cocoapods-downloader 0.8.1
Installing cocoapods-plugins 0.4.1
Installing cocoapods-trunk 0.6.0
Installing cocoapods-try 0.4.3
Installing cocoapods 0.36.1
// Many "using" dependencies
So now when I run:
$ pod --version
0.36.1
And I'm stuck :) Why can't I have newest release version? Maybe pod --version points to the newest version of cocoapods-core instead of only cocoapods, so everything is ok and I have the correct version?
Check if you use Gemfile and there is specified the version of
cocoapods.
You can use specific version by pod *version* action. For example: pod _1.5.0.beta.1_ update or pod _1.5.0.beta.1_ install
For anyone coming to this in an attempt to update cocoapods. After doing all of the above I wasn't able to get this resolved. I then headed to the resolved answer and being unwilling to remove RVM, I tried to resolve this issue another way.
I found that my issue did indeed lie in my Gemfile.
First, run
gem install cocoapods to ensure you have the latest version, or whatever specified version you were looking for downloaded.
Second, ensure your projects Gemfile hasn't specified a cocoapods version number and instead simply specifies it as:
gem "cocoapods"
If yours doesn't, change this and run bundle update to regenerate the Gemfile.lock file and your problem should be solved. If not, go ahead and delete the Gemfile.lock file altogether and then run bundle update. You can easily check to see which gem version will be loaded by opening the Gemfile.lock file and searching for cocoapods-core <version number here>
At this point, you can go into your project and run
pod setup
and then check the cocoapods version with
pod --version
and now FINALLY you are free to run
pod install
to replace the Podfile.lock file and get back to your happy dev life. Hope that helps someone and saves them from burning hours.
It seems something got messed up in my ruby version. I still have no idea what and why. I've managed to fix it via this solution: https://stackoverflow.com/a/25021772/849616. After it everything works correctly.
You might face this issue when it comes migrating to a higher Swift version. Assuming that you already have cocoapods installed, you probably need to run bundle update command (possibly with sudo).
For more details, you could check: https://guides.cocoapods.org/using/a-gemfile.html
Additionally, I'd suggest to do the following:
Install the latest Xcode version.
Clear derived data (not just clean project) in your project.
Run pod update command.
I have the same problem.
In my project, pod --version and gem which cocoapods always return diffrence version.
All I had to do is remove Gemfile.lock in my project and bundle install again. It removed the locked cocoapods version and install a new one.
Hope that helps some one here.
I ran pod install and I've got this error:
Could not find proper version of cocoapods (1.11.3) in any of the sources
and I ran:
bundle install
after that pod install worked properly
After installing cocoapods with sudo gem install cocoapods, attempting to run pod setup returns this error:
Could not find 'cocoapods' (>= 0) among 64 total gem(s) (Gem::LoadError)
Output from sudo gem install cocoapods:
CHANGELOG:
[CocoaPods](https://github.com/CocoaPods/CocoaPods/compare/0.28.0...0.29.0)
• [CocoaPods-core](https://github.com/CocoaPods/Core/compare/0.28.0...0.29.0)
• [cocoapods-downloader](https://github.com/CocoaPods/cocoapods-downloader/compare/0.2.0...0.3.0)
[ bug/enhancement notes removed for brevity]
Successfully installed cocoapods-0.29.0
Parsing documentation for cocoapods-0.29.0
1 gem installed
When I list the gems installed, I do not see cocoapods listed among my Local Gems but I do see 'pod' listed in /usr/local/Cellar/ruby/2.0.0-p0/bin.
System Configuration:
Mac OS 10.9 (upgraded from 10.8)
Xcode: 5.0.2 (upgrade from 4.x)
Ruby path: /usr/local/Cellar/ruby/2.0.0-p0
How can I get cocopods to work for me?
Uninstalling and reinstalling CocoaPods from the Terminal fixed the issue for me (see the CocoaPods documentation for more information):
gem uninstall cocoapods
gem install cocoapods
For me it was
sudo gem install cocoapods
Try:
sudo pod setup
Since you installed cocoapods as supervisor (sudo), there are files that supervisor can see that you can not.
This also means that after you add a pod to a podFile, you'll also need to run
sudo pod install
instead of
pod install
It ultimately might be better to undo the sudo install of cocoa pods and use RVM.
With RVM you can have different versions of gem sets (including different versions of cocoapods, if required). By going this route, you can then bypass having to run pod commands as sudo.
Simple do this thing write below thing in terminal..
sudo gem install -n /usr/local/bin cocoapods
you do not need to install cocapods using sudo
try:
gem install cocoapods
then:
pod
to check if it runs fine