19
0
Fork 0
wiki/HowtoRbenv.md

3.8 KiB

:sources:


On clone le dépôt Git de Rbenv :

$ git clone https://github.com/rbenv/rbenv.git ~/.rbenv


On installe quelques plugins :

$ mkdir ~/.rbenv/plugins $ cd ~/.rbenv/plugins $ git clone https://github.com/rbenv/rbenv-vars.git $ git clone https://github.com/rbenv/ruby-build.git $ git clone https://github.com/rbenv/rbenv-default-gems.git $ git clone https://github.com/rbenv/rbenv-installer.git $ git clone https://github.com/rkh/rbenv-update.git $ git clone https://github.com/rkh/rbenv-whatis.git $ git clone https://github.com/rkh/rbenv-use.git


On configure notre shell (`~/.profile`) pour initialiser Rbenv, en ajoutant ces 2 lignes :

~~~{.bash}
export PATH="~/.rbenv/bin:$PATH"
eval "$(rbenv init -)"

Utilisation

$ rbenv help
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

Installer une version de Ruby

La commande rbenv install --list vous indiquera toutes les versions de Ruby connues (par le plugin "ruby-build").

On installe la version voulue :

$ rbenv install <version>`

Notez que la partition sur laquelle se trouve Rbenv doit avoir les droits d'exécution. Ça n'est pas le cas par défaut sur les installtions Evolix.

Si votre dossier temporaire par défaut n'est pas accessible en execution, vous pouvez en créer un et le spécifier ainsi :

$ mkdir /path/to/exec-tmp
$ TMPDIR=/path/to/exec-tmp rbenv install <version>`

Pour avoir la liste des versions installées :

rbenv versions
* system (set by /home/foo/.rbenv/version)
  2.6.4
  2.6.5
  2.7.0

Changer de version de Ruby

  • rbenv global <version> change la version par défaut pour votre utilisateur.
  • rbenv local <version> change la version pour le dossier courant et ses descendants.
  • rbenv shell <version> change pour la session courante.

Il est aussi possible de créer un fichier .ruby-version à n'importe quel emplacement et Rbenv en tiendra compte pour cet emplacement et ses descendants (c'est ce que fait rbenv local <version>).

Mise à jour de Rbenv

Tous les plugins et Rbenv lui-même peuvent être mis à jour par un simple git pull dans ~/rbenv/ et ~/.rbenv/plugins/.