LoginSignup
1

More than 3 years have passed since last update.

Amazon Linuxでrbenvをインストール

Last updated at Posted at 2020-10-23

依存ライブラリーをインストール

sudo yum -y install gcc
sudo yum -y install make
sudo yum -y install openssl
sudo yum -y install openssl-devel
sudo yum -y install gcc-c++
sudo yum install -y mysql-devel
sudo yum install -y readline-devel
sudo yum install -y libxml2-devel
sudo yum install -y libxslt-devel
sudo yum install -y bzip2

gitをインストール

$ sudo yum -y install git

rbenvをインストール

$ git clone https://github.com/sstephenson/rbenv.git ~/.rbenv
$ echo 'export PATH="$HOME/.rbenv/bin:$PATH"' >> ~/.bash_profile
$ echo 'eval "$(rbenv init -)"' >> ~/.bash_profile
$ exec $SHELL -l

しかしこのままだとrbenv istallが出来ない。

$ rbenv install -v 2.6.2
rbenv: no such command `install'

helpを見てみると、installコマンドが無いのが分かる。

$ rbenv -h
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
   rehash      Rehash rbenv shims (run this after installing executables)
   version     Show the current Ruby version and its origin
   versions    List installed Ruby versions
   which       Display the full path to an executable
   whence      List all Ruby versions that contain the given executable

解決方法

install するには ruby-build プラグインが必要となるのでインストールする。

$ git clone https://github.com/sstephenson/ruby-build.git ~/.rbenv/plugins/ruby-build

helpを見るとinstall(とuninstall)が追加されたのが分かる。

$ rbenv -h
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 installed Ruby versions
   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

rbenv install -v 2.6.2 するとインストールが始まる。
インストール終了後、rbenv versionsで確認できる。

$ rbenv versions
* system
  2.6.2

インストールLog

インストール時のlogファイルはruby-build.xxxxxxxxxxxxxxx.logというファイル名で
/tmp/配下に格納されている。

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
1