How to Install rbenv on Centos/Ubuntu?
How to Install rbenv on Centos/Ubuntu?
Rbenv provides an easy way to install and manage various versions of Ruby on your machine. We can install multiple versions of Ruby and set preferred one as the default version. This will help you ensure that the Ruby version you are developing against matches your production environment. In this article we will explain how to install “rbenv” on Centos machine and manage ruby using rbenv
How to Install Rbenv on Centos/Ubuntu?
On Centos, Run the following command to install rbenv dependencies
1 2 3 | yum install –y git–core zlib zlib–devel gcc–c++ patch readline readline–devel libyaml–devel libffi–devel openssl–devel make bzip2 autoconf automake libtool bison curl sqlite–devel |
Now we can install rbenv, easiest way do do this is by cloning the github repository
Make sure you run this commands as the user which will be running Ruby applications
1 2 3 4 5 6 7 8 9 10 11 | cd ~ git clone git://github.com/sstephenson/rbenv.git .rbenv echo ‘export PATH=”$HOME/.rbenv/bin:$PATH”‘ >> ~/.bash_profile echo ‘eval “$(rbenv init -)”‘ >> ~/.bash_profile source ~/.bash_profile git clone git://github.com/sstephenson/ruby-build.git ~/.rbenv/plugins/ruby-build echo ‘export PATH=”$HOME/.rbenv/plugins/ruby-build/bin:$PATH”‘ >> ~/.bash_profile source ~/.bash_profile |
This installs rbenv into your home directory, and sets the appropriate environment variables.
1 2 3 4 | # rbenv -v rbenv 1.1.0–2–g4f8925a |
Now let us see how to install ruby using rbenv
How to install Ruby using rbenv?
First find out which version of Ruby you want to install . In this example, we will install Ruby 2.3.0
1 2 3 4 | rbenv install –v 2.3.0 rbenv global 2.3.0 |
1 2 3 4 | ~]# ruby -v ruby 2.3.0p0 (2015–12–25 revision 53290) [x86_64–linux] |
To Uninstall a ruby version, run following command
1 2 3 | rbenv uninstall 2.3.0 |
Following command will list the list of Ruby versions installed on the machine
1 2 3 4 | ~]# rbenv versions * 2.3.0 (set by /root/.rbenv/version) |
Following commands are available for rbenv,
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 | rbenv —help Usage: rbenv [] Some useful rbenv commands are: commands List all available rbenv commands local Set or show the local application–specific Ruby version global Set or show the global Ruby version shell Set or show the shell–specific Ruby version install Install a Ruby version using ruby–build uninstall Uninstall a specific Ruby version rehash Rehash rbenv shims (run this after installing executables) version Show the current Ruby version and its origin versions List all Ruby versions available to rbenv which Display the full path to an executable whence List all Ruby versions that contain the given executable |
Please let me know if you face any troubles. Always happy to help ????