概要
VagrantのCentOS7仮想環境にrbenv&Rubyをインストールした記録。
- ホスト:Windows10
- ゲスト:Vagrant + VirtualBox + bento/CentOS-7.7
Gitのインストール
yumによるGitのインストール
suでyumを実行してGitをインストールする。
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 |
[vagrant@localhost ~]$ sudo yum install git Loaded plugins: fastestmirror Loading mirror speeds from cached hostfile * base: ftp.jaist.ac.jp * extras: ftp.jaist.ac.jp * updates: ftp.jaist.ac.jp base | 3.6 kB 00:00 extras | 2.9 kB 00:00 updates | 2.9 kB 00:00 Resolving Dependencies --> Running transaction check ---> Package git.x86_64 0:1.8.3.1-23.el7_8 will be installed --> Processing Dependency: perl-Git = 1.8.3.1-23.el7_8 for package: git-1.8.3.1-23.el7_8.x86_64 --> Processing Dependency: perl(Term::ReadKey) for package: git-1.8.3.1-23.el7_8.x86_64 --> Processing Dependency: perl(Git) for package: git-1.8.3.1-23.el7_8.x86_64 --> Processing Dependency: perl(Error) for package: git-1.8.3.1-23.el7_8.x86_64 --> Running transaction check ---> Package perl-Error.noarch 1:0.17020-2.el7 will be installed ---> Package perl-Git.noarch 0:1.8.3.1-23.el7_8 will be installed ---> Package perl-TermReadKey.x86_64 0:2.30-20.el7 will be installed --> Finished Dependency Resolution Dependencies Resolved ================================================================================ Package Arch Version Repository Size ================================================================================ Installing: git x86_64 1.8.3.1-23.el7_8 base 4.4 M Installing for dependencies: perl-Error noarch 1:0.17020-2.el7 base 32 k perl-Git noarch 1.8.3.1-23.el7_8 base 56 k perl-TermReadKey x86_64 2.30-20.el7 base 31 k Transaction Summary ================================================================================ Install 1 Package (+3 Dependent packages) Total download size: 4.5 M Installed size: 22 M Is this ok [y/d/N]: y Downloading packages: (1/4): perl-Error-0.17020-2.el7.noarch.rpm | 32 kB 00:00 (2/4): perl-Git-1.8.3.1-23.el7_8.noarch.rpm | 56 kB 00:00 (3/4): perl-TermReadKey-2.30-20.el7.x86_64.rpm | 31 kB 00:00 (4/4): git-1.8.3.1-23.el7_8.x86_64.rpm | 4.4 MB 00:00 -------------------------------------------------------------------------------- Total 8.7 MB/s | 4.5 MB 00:00 Running transaction check Running transaction test Transaction test succeeded Running transaction Installing : 1:perl-Error-0.17020-2.el7.noarch 1/4 Installing : perl-TermReadKey-2.30-20.el7.x86_64 2/4 Installing : perl-Git-1.8.3.1-23.el7_8.noarch 3/4 Installing : git-1.8.3.1-23.el7_8.x86_64 4/4 Verifying : git-1.8.3.1-23.el7_8.x86_64 1/4 Verifying : 1:perl-Error-0.17020-2.el7.noarch 2/4 Verifying : perl-Git-1.8.3.1-23.el7_8.noarch 3/4 Verifying : perl-TermReadKey-2.30-20.el7.x86_64 4/4 Installed: git.x86_64 0:1.8.3.1-23.el7_8 Dependency Installed: perl-Error.noarch 1:0.17020-2.el7 perl-Git.noarch 0:1.8.3.1-23.el7_8 perl-TermReadKey.x86_64 0:2.30-20.el7 Complete! |
確認
1 2 |
[vagrant@localhost ~]$ git --version git version 1.8.3.1 |
rbenvのインストール
ユーザー環境へのrbenvのダウンロード
カレントディレクトリーの確認。
1 2 |
[vagrant@localhost ~]$ pwd /home/vagrant |
Gitでユーザー環境にrbenvをclone(ダウンロード)。
1 2 3 4 5 6 |
[vagrant@localhost ~]$ git clone https://github.com/sstephenson/rbenv.git ~/.rbenv Cloning into '/home/vagrant/.rbenv'... remote: Enumerating objects: 2886, done. remote: Total 2886 (delta 0), reused 0 (delta 0), pack-reused 2886 Receiving objects: 100% (2886/2886), 562.66 KiB | 373.00 KiB/s, done. Resolving deltas: 100% (1801/1801), done. |
/home/vagrand
下に.rbenv
フォルダーが作成され、その下にフォルダー・ファイル群が展開される。
.bash_profileの設定
$PATHの確認
1 2 |
[vagrant@localhost ~]$ echo $PATH /usr/local/bin:/usr/bin:/usr/local/sbin:/usr/sbin:/home/vagrant/.local/bin:/home/vagrant/bin |
.bash_profileの確認
1 2 3 4 5 6 7 8 9 10 11 12 |
[vagrant@localhost ~]$ cat ./.bash_profile# .bash_profile # Get the aliases and functions if [ -f ~/.bashrc ]; then . ~/.bashrc fi # User specific environment and startup programs PATH=$PATH:$HOME/.local/bin:$HOME/bin export PATH |
PATHの追加
$echo 'export PATH=通したいパス:$PATH' >> .bash_profile
rbenvの場合は
echo 'export PATH="$HOME/.rbenv/bin:$PATH"' >> ~/.bash_profile
起動時のrbenv init実行設定
echo 'eval "$(rbenv init -)"' >> ~/.bash_profile
設定後の.bash_profile
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 |
[vagrant@localhost ~]$ echo 'export PATH="$HOME/.rbenv/bin:$PATH"' >> ~/.bash_profile [vagrant@localhost ~]$ echo 'eval "$(rbenv init -)"' >> ~/.bash_profile [vagrant@localhost ~]$ cat ./.bash_profile # .bash_profile # Get the aliases and functions if [ -f ~/.bashrc ]; then . ~/.bashrc fi # User specific environment and startup programs PATH=$PATH:$HOME/.local/bin:$HOME/bin export PATH export PATH="$HOME/.rbenv/bin:$PATH" eval "$(rbenv init -)" |
.bash_profile
を修正したら、ターミナルを再起動して.bash_profile
を反映させる。
rbenvの確認
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 |
[vagrant@localhost ~]$ rbenv rbenv 1.1.2-44-gd604acb 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 See `rbenv help <command>' for information on a specific command. For full documentation, see: https://github.com/rbenv/rbenv#readme |
ruby-build
ユーザー環境へのruby-buildのダウンロード
Gitでユーザー環境にruby-buildをclone(ダウンロード)。
1 2 3 4 5 6 7 8 |
[vagrant@localhost ~]$ git clone https://github.com/sstephenson/ruby-build.git ~/.rbenv/plugins/ruby-build Cloning into '/home/vagrant/.rbenv/plugins/ruby-build'... remote: Enumerating objects: 101, done. remote: Counting objects: 100% (101/101), done. remote: Compressing objects: 100% (87/87), done. remote: Total 11408 (delta 78), reused 22 (delta 10), pack-reused 11307 Receiving objects: 100% (11408/11408), 2.42 MiB | 1.97 MiB/s, done. Resolving deltas: 100% (7545/7545), done. |
Ruby
ライブラリーのインストール
gcc, make, openssl-devel, readline-develが必要になるので、yumでインストール。
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 |
[vagrant@localhost ~]$ sudo yum install gcc make openssl-devel readline-devel Loaded plugins: fastestmirror Loading mirror speeds from cached hostfile * base: ftp.jaist.ac.jp * extras: ftp.jaist.ac.jp * updates: ftp.jaist.ac.jp Package gcc-4.8.5-44.el7.x86_64 already installed and latest version Package 1:make-3.82-24.el7.x86_64 already installed and latest version Resolving Dependencies --> Running transaction check ---> Package openssl-devel.x86_64 1:1.0.2k-21.el7_9 will be installed --> Processing Dependency: openssl-libs(x86-64) = 1:1.0.2k-21.el7_9 for package: 1:openssl-devel-1.0.2k-21.el7_9.x86_64 --> Processing Dependency: krb5-devel(x86-64) for package: 1:openssl-devel-1.0.2k-21.el7_9.x86_64 ---> Package readline-devel.x86_64 0:6.2-11.el7 will be installed --> Processing Dependency: ncurses-devel for package: readline-devel-6.2-11.el7.x86_64 --> Running transaction check ---> Package krb5-devel.x86_64 0:1.15.1-50.el7 will be installed --> Processing Dependency: libkadm5(x86-64) = 1.15.1-50.el7 for package: krb5-devel-1.15.1-50.el7.x86_64 --> Processing Dependency: krb5-libs(x86-64) = 1.15.1-50.el7 for package: krb5-devel-1.15.1-50.el7.x86_64 --> Processing Dependency: libverto-devel for package: krb5-devel-1.15.1-50.el7.x86_64 --> Processing Dependency: libselinux-devel for package: krb5-devel-1.15.1-50.el7.x86_64 --> Processing Dependency: libcom_err-devel for package: krb5-devel-1.15.1-50.el7.x86_64 --> Processing Dependency: keyutils-libs-devel for package: krb5-devel-1.15.1-50.el7.x86_64 ---> Package ncurses-devel.x86_64 0:5.9-14.20130511.el7_4 will be installed ---> Package openssl-libs.x86_64 1:1.0.2k-19.el7 will be updated --> Processing Dependency: openssl-libs(x86-64) = 1:1.0.2k-19.el7 for package: 1:openssl-1.0.2k-19.el7.x86_64 ---> Package openssl-libs.x86_64 1:1.0.2k-21.el7_9 will be an update --> Running transaction check ---> Package keyutils-libs-devel.x86_64 0:1.5.8-3.el7 will be installed ---> Package krb5-libs.x86_64 0:1.15.1-46.el7 will be updated ---> Package krb5-libs.x86_64 0:1.15.1-50.el7 will be an update ---> Package libcom_err-devel.x86_64 0:1.42.9-19.el7 will be installed --> Processing Dependency: libcom_err(x86-64) = 1.42.9-19.el7 for package: libcom_err-devel-1.42.9-19.el7.x86_64 ---> Package libkadm5.x86_64 0:1.15.1-50.el7 will be installed ---> Package libselinux-devel.x86_64 0:2.5-15.el7 will be installed --> Processing Dependency: libsepol-devel(x86-64) >= 2.5-10 for package: libselinux-devel-2.5-15.el7.x86_64 --> Processing Dependency: pkgconfig(libsepol) for package: libselinux-devel-2.5-15.el7.x86_64 --> Processing Dependency: pkgconfig(libpcre) for package: libselinux-devel-2.5-15.el7.x86_64 ---> Package libverto-devel.x86_64 0:0.2.5-4.el7 will be installed ---> Package openssl.x86_64 1:1.0.2k-19.el7 will be updated ---> Package openssl.x86_64 1:1.0.2k-21.el7_9 will be an update --> Running transaction check ---> Package libcom_err.x86_64 0:1.42.9-17.el7 will be updated --> Processing Dependency: libcom_err(x86-64) = 1.42.9-17.el7 for package: e2fsprogs-libs-1.42.9-17.el7.x86_64 --> Processing Dependency: libcom_err(x86-64) = 1.42.9-17.el7 for package: e2fsprogs-1.42.9-17.el7.x86_64 --> Processing Dependency: libcom_err(x86-64) = 1.42.9-17.el7 for package: libss-1.42.9-17.el7.x86_64 ---> Package libcom_err.x86_64 0:1.42.9-19.el7 will be an update ---> Package libsepol-devel.x86_64 0:2.5-10.el7 will be installed ---> Package pcre-devel.x86_64 0:8.32-17.el7 will be installed --> Running transaction check ---> Package e2fsprogs.x86_64 0:1.42.9-17.el7 will be updated ---> Package e2fsprogs.x86_64 0:1.42.9-19.el7 will be an update ---> Package e2fsprogs-libs.x86_64 0:1.42.9-17.el7 will be updated ---> Package e2fsprogs-libs.x86_64 0:1.42.9-19.el7 will be an update ---> Package libss.x86_64 0:1.42.9-17.el7 will be updated ---> Package libss.x86_64 0:1.42.9-19.el7 will be an update --> Finished Dependency Resolution Dependencies Resolved ================================================================================ Package Arch Version Repository Size ================================================================================ Installing: openssl-devel x86_64 1:1.0.2k-21.el7_9 updates 1.5 M readline-devel x86_64 6.2-11.el7 base 139 k Installing for dependencies: keyutils-libs-devel x86_64 1.5.8-3.el7 base 37 k krb5-devel x86_64 1.15.1-50.el7 base 273 k libcom_err-devel x86_64 1.42.9-19.el7 base 32 k libkadm5 x86_64 1.15.1-50.el7 base 179 k libselinux-devel x86_64 2.5-15.el7 base 187 k libsepol-devel x86_64 2.5-10.el7 base 77 k libverto-devel x86_64 0.2.5-4.el7 base 12 k ncurses-devel x86_64 5.9-14.20130511.el7_4 base 712 k pcre-devel x86_64 8.32-17.el7 base 480 k Updating for dependencies: e2fsprogs x86_64 1.42.9-19.el7 base 701 k e2fsprogs-libs x86_64 1.42.9-19.el7 base 168 k krb5-libs x86_64 1.15.1-50.el7 base 809 k libcom_err x86_64 1.42.9-19.el7 base 42 k libss x86_64 1.42.9-19.el7 base 47 k openssl x86_64 1:1.0.2k-21.el7_9 updates 493 k openssl-libs x86_64 1:1.0.2k-21.el7_9 updates 1.2 M Transaction Summary ================================================================================ Install 2 Packages (+9 Dependent packages) Upgrade ( 7 Dependent packages) Total download size: 7.0 M Is this ok [y/d/N]: y Downloading packages: No Presto metadata available for base No Presto metadata available for updates (1/18): e2fsprogs-libs-1.42.9-19.el7.x86_64.rpm | 168 kB 00:00 (2/18): keyutils-libs-devel-1.5.8-3.el7.x86_64.rpm | 37 kB 00:00 (3/18): krb5-devel-1.15.1-50.el7.x86_64.rpm | 273 kB 00:00 (4/18): e2fsprogs-1.42.9-19.el7.x86_64.rpm | 701 kB 00:00 (5/18): krb5-libs-1.15.1-50.el7.x86_64.rpm | 809 kB 00:00 (6/18): libcom_err-1.42.9-19.el7.x86_64.rpm | 42 kB 00:00 (7/18): libcom_err-devel-1.42.9-19.el7.x86_64.rpm | 32 kB 00:00 (8/18): libkadm5-1.15.1-50.el7.x86_64.rpm | 179 kB 00:00 (9/18): libselinux-devel-2.5-15.el7.x86_64.rpm | 187 kB 00:00 (10/18): libsepol-devel-2.5-10.el7.x86_64.rpm | 77 kB 00:00 (11/18): libss-1.42.9-19.el7.x86_64.rpm | 47 kB 00:00 (12/18): libverto-devel-0.2.5-4.el7.x86_64.rpm | 12 kB 00:00 (13/18): ncurses-devel-5.9-14.20130511.el7_4.x86_64.rpm | 712 kB 00:00 (14/18): openssl-1.0.2k-21.el7_9.x86_64.rpm | 493 kB 00:00 (15/18): openssl-devel-1.0.2k-21.el7_9.x86_64.rpm | 1.5 MB 00:00 (16/18): openssl-libs-1.0.2k-21.el7_9.x86_64.rpm | 1.2 MB 00:00 (17/18): pcre-devel-8.32-17.el7.x86_64.rpm | 480 kB 00:00 (18/18): readline-devel-6.2-11.el7.x86_64.rpm | 139 kB 00:00 -------------------------------------------------------------------------------- Total 5.1 MB/s | 7.0 MB 00:01 Running transaction check Running transaction test Transaction test succeeded Running transaction Updating : libcom_err-1.42.9-19.el7.x86_64 1/25 Updating : 1:openssl-libs-1.0.2k-21.el7_9.x86_64 2/25 Updating : krb5-libs-1.15.1-50.el7.x86_64 3/25 Installing : libkadm5-1.15.1-50.el7.x86_64 4/25 Updating : libss-1.42.9-19.el7.x86_64 5/25 Updating : e2fsprogs-libs-1.42.9-19.el7.x86_64 6/25 Installing : libcom_err-devel-1.42.9-19.el7.x86_64 7/25 Installing : libsepol-devel-2.5-10.el7.x86_64 8/25 Installing : ncurses-devel-5.9-14.20130511.el7_4.x86_64 9/25 Installing : libverto-devel-0.2.5-4.el7.x86_64 10/25 Installing : pcre-devel-8.32-17.el7.x86_64 11/25 Installing : libselinux-devel-2.5-15.el7.x86_64 12/25 Installing : keyutils-libs-devel-1.5.8-3.el7.x86_64 13/25 Installing : krb5-devel-1.15.1-50.el7.x86_64 14/25 Installing : 1:openssl-devel-1.0.2k-21.el7_9.x86_64 15/25 Installing : readline-devel-6.2-11.el7.x86_64 16/25 Updating : e2fsprogs-1.42.9-19.el7.x86_64 17/25 Updating : 1:openssl-1.0.2k-21.el7_9.x86_64 18/25 Cleanup : e2fsprogs-1.42.9-17.el7.x86_64 19/25 Cleanup : 1:openssl-1.0.2k-19.el7.x86_64 20/25 Cleanup : krb5-libs-1.15.1-46.el7.x86_64 21/25 Cleanup : 1:openssl-libs-1.0.2k-19.el7.x86_64 22/25 Cleanup : e2fsprogs-libs-1.42.9-17.el7.x86_64 23/25 Cleanup : libss-1.42.9-17.el7.x86_64 24/25 Cleanup : libcom_err-1.42.9-17.el7.x86_64 25/25 Verifying : libselinux-devel-2.5-15.el7.x86_64 1/25 Verifying : keyutils-libs-devel-1.5.8-3.el7.x86_64 2/25 Verifying : libss-1.42.9-19.el7.x86_64 3/25 Verifying : libcom_err-1.42.9-19.el7.x86_64 4/25 Verifying : pcre-devel-8.32-17.el7.x86_64 5/25 Verifying : libkadm5-1.15.1-50.el7.x86_64 6/25 Verifying : libverto-devel-0.2.5-4.el7.x86_64 7/25 Verifying : ncurses-devel-5.9-14.20130511.el7_4.x86_64 8/25 Verifying : 1:openssl-1.0.2k-21.el7_9.x86_64 9/25 Verifying : e2fsprogs-libs-1.42.9-19.el7.x86_64 10/25 Verifying : libsepol-devel-2.5-10.el7.x86_64 11/25 Verifying : 1:openssl-libs-1.0.2k-21.el7_9.x86_64 12/25 Verifying : readline-devel-6.2-11.el7.x86_64 13/25 Verifying : 1:openssl-devel-1.0.2k-21.el7_9.x86_64 14/25 Verifying : e2fsprogs-1.42.9-19.el7.x86_64 15/25 Verifying : krb5-devel-1.15.1-50.el7.x86_64 16/25 Verifying : krb5-libs-1.15.1-50.el7.x86_64 17/25 Verifying : libcom_err-devel-1.42.9-19.el7.x86_64 18/25 Verifying : e2fsprogs-libs-1.42.9-17.el7.x86_64 19/25 Verifying : libcom_err-1.42.9-17.el7.x86_64 20/25 Verifying : krb5-libs-1.15.1-46.el7.x86_64 21/25 Verifying : 1:openssl-libs-1.0.2k-19.el7.x86_64 22/25 Verifying : e2fsprogs-1.42.9-17.el7.x86_64 23/25 Verifying : 1:openssl-1.0.2k-19.el7.x86_64 24/25 Verifying : libss-1.42.9-17.el7.x86_64 25/25 Installed: openssl-devel.x86_64 1:1.0.2k-21.el7_9 readline-devel.x86_64 0:6.2-11.el7 Dependency Installed: keyutils-libs-devel.x86_64 0:1.5.8-3.el7 krb5-devel.x86_64 0:1.15.1-50.el7 libcom_err-devel.x86_64 0:1.42.9-19.el7 libkadm5.x86_64 0:1.15.1-50.el7 libselinux-devel.x86_64 0:2.5-15.el7 libsepol-devel.x86_64 0:2.5-10.el7 libverto-devel.x86_64 0:0.2.5-4.el7 ncurses-devel.x86_64 0:5.9-14.20130511.el7_4 pcre-devel.x86_64 0:8.32-17.el7 Dependency Updated: e2fsprogs.x86_64 0:1.42.9-19.el7 e2fsprogs-libs.x86_64 0:1.42.9-19.el7 krb5-libs.x86_64 0:1.15.1-50.el7 libcom_err.x86_64 0:1.42.9-19.el7 libss.x86_64 0:1.42.9-19.el7 openssl.x86_64 1:1.0.2k-21.el7_9 openssl-libs.x86_64 1:1.0.2k-21.el7_9 Complete! |
インストール可能なパッケージの確認
ruby-envでインストール可能なパッケージを確認する。
-list
は最近の安定バージョンのみ表示--list-all
はインストール可能な全バージョンを表示
1 2 3 4 5 6 7 8 9 10 11 12 13 |
[vagrant@localhost ~]$ rbenv install -l 2.5.8 2.6.6 2.7.2 3.0.0 jruby-9.2.14.0 mruby-2.1.2 rbx-5.0 truffleruby-21.0.0 truffleruby+graalvm-21.0.0 Only latest stable releases for each Ruby implementation are shown. Use 'rbenv install --list-all / -L' to show all local versions. |
Rubyのインストール
今回は3.0.0をインストール。3~4分ほどかかった。
1 2 3 4 5 |
[vagrant@localhost ~]$ rbenv install 3.0.0 Downloading ruby-3.0.0.tar.gz... -> https://cache.ruby-lang.org/pub/ruby/3.0/ruby-3.0.0.tar.gz Installing ruby-3.0.0... Installed ruby-3.0.0 to /home/vagrant/.rbenv/versions/3.0.0 |
デフォルトのRubyの設定
通常使うRubyにダウンロードした3.0.0を設定。
1 |
[vagrant@localhost ~]$ rbenv global 3.0.0 |
確認
1 2 |
[vagrant@localhost ~]$ ruby -v ruby 3.0.0p0 (2020-12-25 revision 95aff21468) [x86_64-linux] |
参考サイト