How To Install CocoaPods

Using rbenv

  1. Install or Update rbenv and ruby-build:

    If rbenv is not installed or needs updating, install it using Homebrew:

    brew install rbenv
    brew install ruby-build
    

    Add rbenv to your shell:

    echo 'eval "$(rbenv init -)"' >> ~/.zshrc
    source ~/.zshrc
    
  2. Install a New Ruby Version:

    Install Ruby 3.1.0 or later (e.g., Ruby 3.1.2):

    rbenv install 3.1.2
    
  3. Set the New Ruby Version Globally:

    rbenv global 3.1.2
    
  4. Verify the Ruby Version:

    Check if the Ruby version has been updated:

    ruby -v
    
  5. Install CocoaPods:

    After updating Ruby, install CocoaPods:

    gem install cocoapods
    

Summary

  1. Update Ruby to at least version 3.1.0 using RVM or rbenv.
  2. Install CocoaPods after updating Ruby.

If Ruby 3.1.2 was successfully installed using rbenv, but the global Ruby version has not been updated as expected. You might need to ensure that rbenv is properly initialized in your shell.

Here are some steps to resolve this:

1. Initialize rbenv

Make sure rbenv is properly set up in your shell profile. Add these lines to your ~/.zshrc (or ~/.bashrc or ~/.bash_profile if using bash):

export PATH="$HOME/.rbenv/bin:$PATH"
eval "$(rbenv init -)"

Then, reload your shell configuration:

source ~/.zshrc  # or source ~/.bashrc or ~/.bash_profile

2. Verify rbenv Version

Ensure that rbenv is using the correct Ruby version:

rbenv versions

This should list all installed Ruby versions and show which one is currently active.

3. Rehash rbenv

Run rbenv rehash to ensure that the shims are updated:

rbenv rehash

4. Check Ruby Version

Confirm that the global Ruby version is set correctly:

rbenv global
ruby -v

You should see ruby 3.1.2 as the output of ruby -v.

5. Fix PATH Issues

If Ruby 2.6.10 is still showing up, there might be another Ruby installation on your PATH taking precedence over rbenv. Check your PATH:

echo $PATH

Make sure that ~/.rbenv/shims comes before other Ruby installations.

6. Restart Your Terminal

Sometimes, restarting your terminal can help ensure that all changes take effect properly.

Leave a Reply

Create your own website, free on WordPress.com.Create your own website.
Start free