📜 ⬆️ ⬇️

rbenv and ruby-build: an easy alternative to RVM

RVM is great and powerful, it's hard to argue. But the one who is engaged in local development, probably would like to have something less monstrous. There is such an option, in the basic version it is a set of two utilities, and the name rbenv and ruby-build .


So, we will try to establish this economy. I presume that you have an operating system different from Windows.

Linux

Install rbenv (assuming git, bash):
$ 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

')
rbenv provides the ability to switch versions of Ruby, but has nothing to do with installing them; ruby-build is intended for this.

By default, ruby-build wants to be installed in / usr / local, but we will not pollute anything, but put it in the home folder:
export PREFIX="~/.ruby-build"; ./install.sh
$ echo 'export PATH="$HOME/.ruby-build/bin:$PATH"' >> ~/.bash_profile

Osx

Everything is easier nowhere:
$ brew update
$ brew install rbenv
$ brew install ruby-build

Further

Well, now you can run:
rbenv install 1.9.3-p0
So, now in our ~ / .rbenv / versions folder is a new version of Ruby.
$rbenv versions
1.9.3-p0

Let's make it active:
$rbenv global 1.9.3-p0
$rbenv versions
* 1.9.3-p0 (set by RBENV_VERSION environment variable)
$ ruby -v
ruby 1.9.3p0 (2011-10-30 revision 33570) [i686-linux]


The author strongly recommends using the Bundler , but for yoga lovers, there is a rbenv-gemset plugin .

Ps. Yes, after installing any gems that install binary files, you need to run:
rbenv rehash

Have a good use!

Source: https://habr.com/ru/post/131836/


All Articles