0
0

AlmaLinux9環境にrbenv・ruby3をインストールする

Last updated at Posted at 2023-12-19

環境

  • AlmaLinux 9.3
  • rbenv 1.2.0-83
  • ruby 3.2.2

個人占有の開発環境のため、各アプリのユーザーが共用できるようにシステムワイドにインストールします。rbenv、rubyともにインストール・アップデートなどはrootユーザーで操作する想定です。

rbenvインストール

# git clone https://github.com/rbenv/rbenv.git /usr/local/rbenv

git cloneで最新のrbenvをインストールします。

# echo 'export RBENV_ROOT=/usr/local/rbenv
export PATH="$PATH:$RBENV_ROOT/bin"
eval "$(rbenv init -)"' > /etc/profile.d/rbenv.sh
# source /etc/profile
# rbenv --version
> rbenv 1.2.0-83-g325abac

パスを通すなどの必要な処理を記述しますが、全ユーザーに一律適用させるために /etc/profile.d/rbenv.sh として保存しています。

rbenvプラグインインストール

# mkdir -p ${RBENV_ROOT}/plugins && pushd $_
# git clone https://github.com/rbenv/ruby-build.git
# git clone https://github.com/rbenv/rbenv-default-gems.git
# git clone https://github.com/rkh/rbenv-update.git
# popd
# echo 'bundler' > ${RBENV_ROOT}/default-gems
  • rbenv-default-gems: rbenv install後に指定のgemを自動でインストールしてくれる
  • rbenv-update: rbenv updateコマンドでrbenv及びプラグインを全てgit pullしてくれる

rubyインストール

# rbenv install --list
# rbenv install 3.2.2 && rbenv global 3.2.2 && rbenv rehash
==> Downloading ruby-3.2.2.tar.gz...
(省略)
BUILD FAILED (AlmaLinux 9.3 on x86_64 using ruby-build 20231211)

インストールを実施したところ失敗に終わりました。

インストールログを確認すると以下の記述が。

conftest.c:3:10: 致命的エラー: yaml.h: そのようなファイルやディレクトリはありません

libyaml-develインストール

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

libyaml-develをインストールします。RHEL7系・8系におけるPowerToolsは、9系においてはCRBという名称に変更になっています。

rubyインストール2

# rbenv install 3.2.2 && rbenv global 3.2.2 && rbenv rehash
# ruby --version
> ruby 3.2.2
# gem --version
> 3.4.10
# bundle --version
> Bundler version 2.5.1

改めてrubyをインストールします。

併せてbundlerもインストールされていることを確認します。

0
0
0

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
0
0