As a prerequisite, a virtual environment created on VMware. Install ruby using rbenv from a fresh state where the OS is installed.
The reference article is here. First, install git. For the time being, make sure that git is not installed by default.
$ git
command'git'Cannot be found. You can install it in the following ways:
sudo apt install git
Then install.
$ sudo apt install git
For the time being, leave the log at the time of installation as text. After installation, make the following settings.
$ git config --global user.name [User name]
$ git config --global user.email [mail address]
Since the installation of git is completed, install Ruby from here. First, download rbenv.
$ git clone https://github.com/rbenv/rbenv.git ~/.rbenv
$ git clone https://github.com/rbenv/ruby-build.git ~/.rbenv/plugins/ruby-build
Add the following description to .bashrc (you can write a string to a file with echo'string'>>'filename').
$ echo 'export PATH="$HOME/.rbenv/bin:$PATH"' >> ~/.bashrc
$ echo 'eval "$(rbenv init -)"' >> ~/.bashrc
After executing, if you check the contents of .bashrc with an editor, you can see that the echoed content is added to the end of the file.
Read the contents of .bashrc with the source command.
$ source ~/.bashrc
Check the version of Ruby that can be installed
$ rbenv install -l
2.5.8
2.6.6
2.7.1
jruby-9.2.12.0
maglev-1.0.0
mruby-2.1.1
rbx-5.0
truffleruby-20.1.0
truffleruby+graalvm-20.1.0
Only latest stable releases for each Ruby implementation are shown.
Use 'rbenv install --list-all' to show all local versions.
It seems that only 2.5 to 2.7 within the support range can be installed. Although the version is different from the reference book, I decided to install it with 2.5.8.
$ rbenv install 2.5.8
Downloading ruby-2.5.8.tar.bz2...
-> https://cache.ruby-lang.org/pub/ruby/2.5/ruby-2.5.8.tar.bz2
Installing ruby-2.5.8...
WARNING: ruby-2.5.8 is nearing its end of life.
It only receives critical security updates, no bug fixes.
BUILD FAILED (Ubuntu 20.04 using ruby-build 20200727)
Inspect or clean up the working tree at /tmp/ruby-build.20200728011639.10883.ljBQV0
Results logged to /tmp/ruby-build.20200728011639.10883.log
Last 10 log lines:
checking for ruby... false
checking build system type... x86_64-pc-linux-gnu
checking host system type... x86_64-pc-linux-gnu
checking target system type... x86_64-pc-linux-gnu
checking for gcc... no
checking for cc... no
checking for cl.exe... no
configure: error: in `/tmp/ruby-build.20200728011639.10883.ljBQV0/ruby-2.5.8':
configure: error: no acceptable C compiler found in $PATH
See `config.log' for more details
I got an error. It looks like an error saying that the C compiler is not included, so try installing gcc.
$ sudo apt install gcc
It ended normally. Also here, record the installation log as text for the time being.
Install ruby with rbenv again
$ rbenv install 2.5.8
Downloading ruby-2.5.8.tar.bz2...
-> https://cache.ruby-lang.org/pub/ruby/2.5/ruby-2.5.8.tar.bz2
Installing ruby-2.5.8...
WARNING: ruby-2.5.8 is nearing its end of life.
It only receives critical security updates, no bug fixes.
BUILD FAILED (Ubuntu 20.04 using ruby-build 20200727)
Inspect or clean up the working tree at /tmp/ruby-build.20200728013413.16282.OsujhX
Results logged to /tmp/ruby-build.20200728013413.16282.log
Last 10 log lines:
checking for _setjmp as a macro or function... yes
checking for sigsetjmp as a macro or function... no
checking for setjmp type... __builtin_setjmp
checking for prefix of external symbols... NONE
checking pthread.h usability... yes
checking pthread.h presence... yes
checking for pthread.h... yes
checking if make is GNU make... ./configure: line 27352: make: command not found
no
checking for safe null command for make... configure: error: no candidate for safe null command
I got an error again. This time make is not installed! Error.
$ sudo apt install make
As usual, leave the installation log as text.
This time, install ruby with rbenv.
$ rbenv install 2.5.8
The Ruby openssl extension was not compiled.
The Ruby readline extension was not compiled.
The Ruby zlib extension was not compiled.
Try running `apt-get install -y libssl-dev libreadline-dev zlib1g-dev` to fetch missing dependencies.
Another error, apparently due to the lack of "openssl", "readline" and "zlib". For the time being, try to follow the instructions.
$ apt-get install -y libssl-dev libreadline-dev zlib1g-dev
This is completed without any problems. Install again with rbenv.
$ rbenv install 2.5.8
Downloading ruby-2.5.8.tar.bz2...
-> https://cache.ruby-lang.org/pub/ruby/2.5/ruby-2.5.8.tar.bz2
Installing ruby-2.5.8...
WARNING: ruby-2.5.8 is nearing its end of life.
It only receives critical security updates, no bug fixes.
Installed ruby-2.5.8 to /home/kei/.rbenv/versions/2.5.8
I was able to install it!
Finally, specify the version with rbenv and complete.
$ rbenv global 2.5.8
Also check the version.
$ ruby -v
ruby 2.5.8p224 (2020-03-31 revision 67882) [x86_64-linux]
Recommended Posts