skip to Main Content

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)

4

Answers


  1. 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.

    Login or Signup to reply.
  2. 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

    Login or Signup to reply.
  3. 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.

    Login or Signup to reply.
  4. Remove cocoapods:

    sudo gem uninstall cocoapods
    

    Then instal again:

    sudo gem install -n /usr/local/bin cocoapods
    
    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search