Ways to manage Ruby versions with rbenv _ruby topics

Source: Internet
Author: User
Tags readline rehash git clone

Rbenv is used to manage multiple versions of Ruby in the user directory installation and use, and RVM two select one to use. Specific differences are documented in the rbenv, and there are also discussions in the community.
System Requirements

OS X: Find a good place to download Xcode.app from the App Store, run it after installation, and install Command line Tools in the Downloads setup.

Linux: Install the development environment (compile link tools and ruby dependencies) if only JRuby have JRE.
Install rbenv

On OS X you can install directly with homebrew, and the following is the manual installation process. (without zsh, replace the child's shoes with your own shell configuration file)

git clone git://github.com/sstephenson/rbenv.git ~/.rbenv
# used to compile and install ruby
git clone git://github.com/ Sstephenson/ruby-build.git ~/.rbenv/plugins/ruby-build
# is used to manage gemset, optional, because there is no need for bundler to
git clone git:// Github.com/jamis/rbenv-gemset.git ~/.rbenv/plugins/rbenv-gemset
# After installing gems via GEM command without manually entering the Rbenv rehash command, recommend
git clone git://github.com/sstephenson/rbenv-gem-rehash.git ~/.rbenv/plugins/rbenv-gem-rehash
# via RBENV update command to update rbenv and all plug-ins and recommend
git clone https://github.com/rkh/rbenv-update.git ~/.rbenv/plugins/rbenv-update

and put the following code in the ~/.bash_profile.

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

Note Unubtu Please put in ~/.BASHRC, zsh user is ~/.ZSHRC

And then re-opened a terminal to perform the rbenv.
use
Install Ruby

rbenv Install--list # list all Ruby versions
rbenv install 1.9.3-p392   # install 1.9.3-p392 rbenv install jruby-1.7.3  # ann Pack jruby-1.7.3

List version

rbenv versions        # List installed versions
rbenv version        # List The versions that are in use

Set version

Rbenv Global 1.9.3-p392   # defaults to using
the 1.9.3-p392 rbenv Shell 1.9.3-p392    # The current shell uses 1.9.3-p392, which sets a ' rbenv_ve Rsion ' environment variable
rbenv local jruby-1.7.3   # The current directory uses jruby-1.7.3 and generates a '. Rbenv-version ' file

Resolve MacOSX the method of compiling Ruby without entering Chinese in IRB

Install the homebrew readline, then enter the source directory, recompile the installation Readline.bundle

Brew Install ReadLine
Brew link readline
cd src/ruby-1.9.3-p392/ext/readline
Ruby Extconf.rb- with-readline-dir=$ (Brew--prefix readline) make
Install

The solution under the rbenv

Brew Install ReadLine
configure_opts= "--disable-install-doc--with-readline-dir=$ (Brew--prefix readline)" Rbenv Install 1.9.3-p392

For questions about Ruby-2.0.0-p0 on OS X 10.7+, see: Https://github.com/sstephenson/ruby-build/wiki
other

Rbenv Rehash         # You must execute this command after switching the ruby version and executing the bundle install
rbenv IRB       # Lists the full path of the IRB command
which when Ce IRB       # Lists the version containing the IRB command

Use Gemset under Rbenv
Brief introduction

The most convenient thing in RVM is Gemset. In fact, rbenv can also use Gemset through Plug-ins
installation

If you use brew under MacOS, a command is done.

Brew Install Rbenv-gemset

Use
Create a Gemset

Rbenv Gemset Create 1.9.3-p392 Ruby-china

Specific Use method

In the root directory of the project, put the name of the gemset you want to use in the. rbenv-gemsets file. Executing the bundle command with a. rbenv-gemsets file is the operation of the set Gemset

  echo Ruby-china > Rbenv-gemsets

In the absence of the. rbenv-gemsets file in the current directory, the Gemset of the current version of Ruby is performed when the bundle command (without specifying the--path parameter) is executed. is equivalent to the role of global gemset in RVM.

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.