3.10.2015

Install Ruby via RVM on CentOS 6.5

Got install from here.
RVM best practices here.
How to use RVM gemsets here.
How to use Bundler here.
1. Install pre-requisites
# yum groupinstall -y development

2. Install RVM
# curl -L get.rvm.io | bash -s stable

3. Create system environment for RVM
# source /etc/profile.d/rvm.sh

4. Install Ruby
# rvm reload
# rvm install 2.2.1

5. Check version of ruby installed
# ruby --version

6. To see all rubies installed
# rvm list rubies
rvm rubies
=* ruby-2.2.1 [ x86_64 ]
# => - current
# =* - current && default
#  * - default

7. To set a Ruby version as the default
# rvm use 2.2.1 --default
Using /usr/local/rvm/gems/ruby-2.2.1

8. Shortcut - create a new gemset along with a fresh .rvmrc in our project directory
# cd projects/dev/phoenix
# rvm --rvmrc --create use 2.2.1@phoenix
ruby-2.2.1 - #gemset created /usr/local/rvm/gems/ruby-2.2.1@phoenix
ruby-2.2.1 - #generating phoenix wrappers..........
Using /usr/local/rvm/gems/ruby-2.2.1 with gemset phoenix

9. To ignore rmvrc warnings ...
# rvm rvmrc warning ignore all.rvmrcs

10. Now when we cd to our project directory we get a confirmation which ruby-version and gemset we are using...
dev]# cd phoenix/
Using: /usr/local/rvm/gems/ruby-2.2.1@phoenix

11. Let's make use of bundler to make it easy to track and install the exact gems and versions for our project
# gem install bundler

12. Create a Gemfile
# bundle init
Writing new Gemfile to /root/projects/dev/phoenix/Gemfile

13. Add gems to Gemfile
# vi Gemfile
source "https://rubygems.org"
# 1. de facto XML/HTML parsing library
gem 'nokogiri'

14. Now, let's install all gems we listed in the Gemfile
# bundle install

To create and use gemsets the longer way:
a. Create gemset
# rvm gemset create my_proj

b. Use the gemset
# rvm gemset use my_proj

c. Install a gem
# gem install package_name

d. Wipe all gems installed
# rvm gemset empty my_proj

e. Delete the gemset
# rvm gemset delete my_proj

f. Check your current gemset
# rvm gemset name

No comments:

Post a Comment