Introduction
Sometimes the following error occurs when installing cocoapods
ERROR: Error installing cocoapods: activesupport requires Ruby version >= 2.2.2.
This means that your Ruby environment needs to be updated. I will take the method of updating ruby under Mac OS 10.11 as an example, and talk about the detailed steps to update the Ruby environment.
Cause and Solution
During the installation of cocoapods, it is prompted that the Ruby version is above 2.2.2, and the currently used Ruby version is 1.8.7 that comes with the Mac system. So need to upgrade Ruby. The following are three ways to install Ruby:
1. Download ruby source code, compile, install
2. Use the installation package that comes with the distribution, install
3. Use rvm to install
Detailed steps to install Ruby through rvm
It is still recommended that you upgrade Ruby through rvm.
1> Install ram
RVM: Ruby Version Manager, Ruby version manager, including Ruby version management and Gem library management (gemset)
$ curl -L get.rvm.io | bash -s stable
2> Load the file and test whether the installation is normal (follow the prompts)
$ source ~/.bashrc
$ source ~/.bash_profile
$ source ~/.profile
$ rvm -v
3>If there is the following prompt, please reload rvm
A RVM version 1.27.0 (latest) is installed yet 1.25.23 (stable) is loaded.
Please do one of the following:
* 'rvm reload'
* open a new shell
* 'echo rvm_auto_reload_flag=1 >> ~/.rvmrc' # for auto reload with msg.
* 'echo rvm_auto_reload_flag=2 >> ~/.rvmrc' # for silent auto reload.
input the command:
$ rvm reload
$ rvm -v
4> View the current ruby version and get the rvm list
$ ruby -v
$ rvm list known
5> Possible errors in installing ruby (if no errors, please skip to step 6)
$ rvm install 2.3
Error 1: When installing ruby, the following error may be reported, prompting Updating system[YourMacName] password required for 'port -dv self update', as follows:
Solution:
make an update:
$ sudo port self update
After the update is completed, as shown in the figure:
Error 2:
Or you may encounter the following error because Homebrew needs to be installed.
Error running 'requirements_osx_port_libs_install curl-ca-bundle automake libtool libyaml libffi libksba',
showing last 15 lines of /Users/acewill/.rvm/log/1468253599_ruby-2.3.0/package_install_curl-ca-bundle_automake_libtool_libyaml_libffi_libksba.log
Solution:
Refer to the question on stack overflow Installing RVM: "Requirements installation failed with status: 1."
Homebrew needs to be installed , via the following command:
ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"
6> Reinstall ruby
After the installation is complete, re-execute the command to install cocoapods.
$ rvm install 2.3
7> Install rails
$ gem install rails
8>Uninstall ruby method
Get ruby installed list, then uninstall ruby
$ rvm list
$ rvm remove 2.3
Recommended information:
Other rvm commonly used commands
cocoapods: Summary of common errors
Reference:
Updating Ruby on Mac