Install using bundler in Ruby Environment to manage multiple versions of Gem_ruby topics

Source: Internet
Author: User
Tags mkdir versions

With RBENV to manage multiple versions of the Ruby environment, we also need a tool to manage multiple versions of gems (such as rails), which is bundler, the project background is not in detail, need to understand directly to the official website http://bundler.io/, There are only a few practical experiences to use here.

Installation

Gem Install Bundler

Use

mkdir App1; CD App1;
echo "Source ' https://ruby.taobao.org/'" > Gemfile
echo "Gem ' rails, ' 4.1.0 '" >> gemfile
Bundle Install

The above code installs the Rails 4.1.0 under App1, uses bundle EXEC rails-v to view the rails version that is used under the current directory, and the display content should be rails 4.1.0, also at this time through bundle exec rails new. --force overwrite the original gemfile, the version of the rails used by the app at this time is 4.1.0.

mkdir app2; CD app2;
echo "Source ' https://ruby.taobao.org/'" > Gemfile
echo "Gem ' rails, ' 3.2.13 '" >> gemfile
Bundle Install

The code above creates a second App2 folder and installs rails via bundler 3.2.13 also through bundle exec rails new. --force can generate applications based on the Rails 3.2.13 version.

With the above two versions installed, you can see from the Gem list--local that rails has two versions, shown as Rails (4.1.0, 3.2.13), and bundler intelligently judge the rails version of each project to ensure that the application runs correctly, But the premise is to execute the original command by using the bundle EXEC command, for example:

Bundle EXEC Rails s
bundle exec rake db:create
...

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.