YASD-TECH
YASD TECH
# Linux

AlmaLinux9にRVMでRuby3.2.2を入れる

投稿日:2024/4/25

更新日:2024/5/5

ttitleImage

AlmaLinux9にRVMでRuby3.2.2を入れる際につまり、有力な記事が出てこず、かなり時間がかかったので備忘録です。

RVMインストール

公式サイトに従って入れていきます。

Terminal
$ gpg --keyserver keyserver.ubuntu.com --recv-keys 409B6B1796C275462A1703113804BB82D39DC0E3 7D2BAF1CF37B13E2069D6956105BD0E739499BDB

$ source /etc/profile.d/rvm.sh

Rubyインストール

ここからが問題。

Terminal
$ rvm install 3.2.2
Searching for binary rubies, this might take some time.
No binary rubies available for: centos/9/aarch64/ruby-3.2.2.
Continuing with compilation. Please read 'rvm help mount' to get more information on binary rubies.
Checking requirements for centos.
Installing requirements for centos.
Installing required packages: patch, autoconf, automake, bison, bzip2, gcc-c++, libffi-devel, libtool, make, patch, readline-devel, ruby, sqlite-devel, zlib-devel, glibc-headers, glibc-devel, openssl-devel...............................................................
Requirements installation successful.
Installing Ruby from source to: /usr/local/rvm/rubies/ruby-3.2.2, this may take a while depending on your cpu(s)...
ruby-3.2.2 - #downloading ruby-3.2.2, this may take a while depending on your connection...
  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed
100 19.5M  100 19.5M    0     0  11.1M      0  0:00:01  0:00:01 --:--:-- 11.1M
ruby-3.2.2 - #extracting ruby-3.2.2 to /usr/local/rvm/src/ruby-3.2.2.....
ruby-3.2.2 - #autogen.sh.
ruby-3.2.2 - #configuring.............................................................................
ruby-3.2.2 - #post-configuration..
ruby-3.2.2 - #compiling...................................................................................................
ruby-3.2.2 - #installing...............
Error running '__rvm_make install',
please read /usr/local/rvm/log/1698411567_ruby-3.2.2/install.log
There has been an error while running make install. Halting the installation.

/usr/local/rvm/log/1698411567_ruby-3.2.2/install.logを確認すると以下エラー

Terminal
*** Following extensions are not compiled:

psych:

	Could not be configured. It will not be installed.

	Check ext/psych/mkmf.log for more details.

*** Fix the problems, then remove these directories and try again if you want.

ググるとlibyaml-develが必要と出たので入れてみる

Terminal
$ dnf install libyaml-devel
Last metadata expiration check: 0:26:11 ago on Fri Oct 27 12:56:01 2023.
No match for argument: libyaml-devel

libyaml-develが存在しないとのエラー。

色々ググった結果、どうやらデフォルトのリポジトリにlibyaml-develが存在せず、とってこれないとのこと

解決

インストールする時にオプションを指定して取ってくリポジトリを指定してインストールする。

Terminal
# dnf install --enablerepo=crb libyaml-devel

もう一度試す

Terminal
$ rvm reinstall ruby-3.2.2
ruby-3.2.2 - #removing src/ruby-3.2.2..
ruby-3.2.2 - #removing rubies/ruby-3.2.2..
Searching for binary rubies, this might take some time.
No binary rubies available for: centos/9/aarch64/ruby-3.2.2.
Continuing with compilation. Please read 'rvm help mount' to get more information on binary rubies.
Checking requirements for centos.
Requirements installation successful.
Installing Ruby from source to: /usr/local/rvm/rubies/ruby-3.2.2, this may take a while depending on your cpu(s)...
ruby-3.2.2 - #downloading ruby-3.2.2, this may take a while depending on your connection...
ruby-3.2.2 - #extracting ruby-3.2.2 to /usr/local/rvm/src/ruby-3.2.2.....
ruby-3.2.2 - #autogen.sh.
ruby-3.2.2 - #configuring.............................................................................
ruby-3.2.2 - #post-configuration..
ruby-3.2.2 - #compiling....................................................................................................
ruby-3.2.2 - #installing.....................
ruby-3.2.2 - #making binaries executable...
Installed rubygems 3.4.10 is newer than 3.0.9 provided with installed ruby, skipping installation, use --force to force installation.
ruby-3.2.2 - #gemset created /usr/local/rvm/gems/ruby-3.2.2@global
ruby-3.2.2 - #importing gemset /usr/local/rvm/gemsets/global.gems...........................................................
ruby-3.2.2 - #generating global wrappers........
ruby-3.2.2 - #gemset created /usr/local/rvm/gems/ruby-3.2.2
ruby-3.2.2 - #importing gemsetfile /usr/local/rvm/gemsets/default.gems evaluated to empty gem list
ruby-3.2.2 - #generating default wrappers........
ruby-3.2.2 - #adjusting #shebangs for (gem irb erb ri rdoc testrb rake).
Install of ruby-3.2.2 - #complete 
Ruby was built without documentation, to build it run: rvm docs generate-ri
Making gemset ruby-3.2.2 pristine..................................................................
Making gemset ruby-3.2.2@global pristine...................................................................

無事通りました!

どうやらlibyaml-develはcrbというリポジトリに存在しており、これを指定しないとインストールできないようでした!

追記

CRBリポジトリを常に有効化しておきたい場合のTips

/etc/yum.repos.d/almalinux-crb.repoのファイルを修正することでデフォルトでCRBリポジトリを有効化できる

Terminal
$ vi /etc/yum.repos.d/almalinux-crb.repo 

[crb]
name=AlmaLinux $releasever - CRB
mirrorlist=https://mirrors.almalinux.org/mirrorlist/$releasever/crb
# baseurl=https://repo.almalinux.org/almalinux/$releasever/CRB/$basearch/os/
enabled=0
#########上記をenabled=1に変更#####################
gpgcheck=1
countme=1
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-AlmaLinux-9
metadata_expire=86400
enabled_metadata=0

デフォルトで有効化するデメリットってあんのかな、、、

Index

  • RVMインストール
  • Rubyインストール
  • 解決
  • 追記