Install and use bundler in Ruby to manage multiple versions of gem and rubybundler

Source: Internet
Author: User

Install and use bundler in Ruby to manage multiple versions of gem and rubybundler

With rbenv to manage a multi-version ruby environment, we also need a tool that can manage multiple versions of gem (such as rails), that is, bundler. The project background is not detailed, for more information, visit http://bundler.io/on the official website.

Install

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 rails 4.1.0 under app1, use bundle exec rails -v to view the version of rails used in the current directory, the display content should be Rails 4.1.0, also at this time through bundle exec rails new. Gemfile, the rails version 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 above code creates a second app2 folder and installs rails 3.2.13 through bundler. Also through bundle exec rails new. --Force can generate applications based on rails 3.2.13

After installing the above two versions, you can see through the gem list --local that there are two versions of rails, which are displayed as rails (4.1.0, 3.2.13). The application runs correctly, but only if the original command is executed 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.