rbenv es un gestor de versiones de Ruby, que nos facilitará la instalación y la selección de la versión correspondiente para cada proyecto.
Para instalarlo, basta con ejecutar los siguientes comandos (notar que requieren que git esté instalado):
git clone https://github.com/rbenv/rbenv.git ~/.rbenv
echo 'export PATH="$HOME/.rbenv/bin:$PATH"' >> ~/.bashrc
echo 'eval "$(rbenv init -)"' >> ~/.bashrc
git clone https://github.com/rbenv/ruby-build.git ~/.rbenv/plugins/ruby-build
Una vez instalado, cerrar la terminal, abrir una nueva y comprobar si la instalación fue satisfactoria corriendo el comando rbenv
, el cual debería imprimir algo similar a esto:
rbenv 1.0.0-30-g0c7224a
Usage: rbenv <command> [<args>]
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
See `rbenv help <command>' for information on a specific command.
For full documentation, see: https://github.com/rbenv/rbenv#readme
Una vez instalado rbenv
, instalar una versión de Ruby es tan sencillo como correr este comando:
rbenv install 2.3.1
Luego, para comprobar se puede correr el comando ruby -v
, que debería arrojar algo parecido a:
ruby 2.3.1p112 (2016-04-26 revision 54768) [x86_64-linux]
Para no depender de internet, vamos a ejecutar un servidor de gemas en el server. Una vez que esté corriendo, hay que configurar los clientes para que sepan que pueden buscar gemas ahí.
Asumiendo que el servidor tiene la IP 192.168.88.2
y el gem server
está corriendo en el puerto 8808
, esto se logra con el siguiente comando:
gem sources -a http://192.168.88.2:8808
Luego de hacer :
rbenv install 2.3.1
tuve que hacer un:
sudo apt install ruby