Common Solution to failure of installing the gem package in ruby

Source: Internet
Author: User

The ruby language is still updated frequently. However, a large number of versions make Library compatibility a big problem. Some gems explicitly do not support ruby earlier than a specific version, while some gems are not compatible with higher versions. In addition, the gem itself also has a version, which is a mess of porridge. Even ruby version management tools such as rvm and rbenv cannot be used. And from time to time, some other environment settings also make trouble for you. Therefore, when using ruby programs, you should be cautious when upgrading ruby or various gem versions, so that you can avoid getting yourself stuck.

Of course, you can't just scale it down. In some cases, you still have to upgrade it. For example, you want to use the new ruby or gem features. Whatever software I use, I like to upgrade to the latest version, and ruby programs are no exception. After a long time, I have learned some experience. I hope you can avoid these pitfalls and upgrade them boldly.

Because I use mac, these tips are based on MAC.

When an error occurs when running a ruby script or bundle install, you must carefully check the error log. If you have a clear error log, you can solve the problem by yourself. If you do not know how to solve the problem, you can select the keyword google. Generally, you can find a solution. I am afraid that I still don't know how to do it after google circles. You can try the following methods.

Upgrade ruby to a minor version.

First, upgrade the current rvm to the latest version.
Copy codeThe Code is as follows: $ rvm get stable
Check the currently used ruby version and the available ruby version on the server.
Copy codeThe Code is as follows: $ rvm list
$ Rvm list known
Although you do not plan to upgrade the main ruby version, you can try to upgrade the minor version to see if it can solve the problem. For example, your ruby is currently using a ruby-1.9.3-p448, but the latest version of 1.9.3 that is currently available is a ruby-1.9.3-p545. You can switch to this new version to see if the problem can be solved.
Copy codeCode: $ rvm install ruby-1.9.3-p545

$ Rvm use ruby-1.9.3-p545
Make sure Xcode and Command line developer tools are in the latest version.
Make sure that the local Xcode command line developer tools is installed and the latest version. After upgrading Xcode to the latest version, enter the following command line:
Copy codeThe Code is as follows: $ xcode-select-install
This will pop up an upgrade dialog box to upgrade the corresponding software.

Make sure GCC is the latest version.
Check the gcc version of the current computer.
Copy codeThe Code is as follows: $ gcc-v
If you need to update gcc, homebrew is recommended. First, update homebrew.
Copy codeThe Code is as follows: $ brew update
Enter the following command.

Copy codeThe Code is as follows: $ brew tap homebrew/dupes
$ Brew search gcc
Brew will tell you the latest gcc version. For example, a apple-gcc42. Then install the new version gcc.
Copy codeThe Code is as follows: $ brew install apple-gcc42
Then, check whether the gcc version is applied to the system.
Copy codeThe Code is as follows: $ which gcc-4.2
/Usr/local/bin/gcc-4.2
Basically, some of the above checks will solve a batch of problems caused by the ruby environment.

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.