【Ruby】BUILD FAILED (Ubuntu 22.04 using ruby-build 20230615)

ネコニウム研究所

PCを利用したモノづくりに関連する情報や超個人的なナレッジを掲載するブログ

【Ruby】BUILD FAILED (Ubuntu 22.04 using ruby-build 20230615)

2023-7-25 | ,

Ubuntu 22にrbenvを使ってRuby 3.2.2をインストールしようとしたらBUILD FAILEDになるのをなんとかしたい!

こんな感じのエラー。

BUILD FAILED (Ubuntu 22.04 using ruby-build 20230615)

Inspect or clean up the working tree at /tmp/ruby-build.20230709021051.16121.emnZFa
Results logged to /tmp/ruby-build.yyyyMMddhhmmss.msec.log

Last 10 log lines:
transform_mjit_header: SKIPPED to transform: getlogin_r, pread64, pread, read, bsearch, fread_unlocked, fgets_unlocked, fread, fgets, vdprintf, dprintf, vfprintf, vprintf, printf, fprintf, getline, putchar_unlocked, putc_unlocked, fputc_unlocked, putchar, getchar_unlocked, getc_unlocked, fgetc_unlocked, getchar
ln -sf ../../../.ext/include/x86_64-linux/rb_mjit_min_header-3.2.2.h include/ruby-3.2.0/x86_64-linux/rb_mjit_min_header-3.2.2.h
Generating RDoc documentation
/tmp/ruby-build.20230709021051.16121.emnZFa/ruby-3.2.2/lib/yaml.rb:3: warning: It seems your ruby installation is missing psych (for YAML output).
To eliminate this warning, please install libyaml and reinstall your ruby.
uh-oh! RDoc had a problem:
cannot load such file -- psych

run with --debug for full backtrace
make: *** [uncommon.mk:598: rdoc] Error 1

長文エラーで泣きそう。

概要

今回の記事では、Ubuntu 22にrbenvを使ってRuby 3.2.2をインストールしようとしたらBUILD FAILEDになるのをなんとかする手順を掲載する。

環境

  • Ubuntu 22.04.2 LTS
  • rbenv 1.2.0-67-g3112172
  • Ruby 3.2.2

手順書

このBUILD FAILEDは、Ruby 3.2.2のビルドに必要なライブラリいろいろgccやらlibyaml-devやらなんやらがインストールされていないと発生する。

下記のコマンドを実行して、必要なライブラリ一気にインストールする。

sudo apt install libyaml-dev libffi-dev build-essential libssl-dev zlib1g-dev

インストールが終わったら、rbenvでRuby 3.2.2をインストールできるようになってるはず。

rbenv install 3.2.2

下記のような感じになればインストール成功!


To follow progress, use 'tail -f /tmp/ruby-build.yyyyMMddhhmmss.msec.log' or pass --verbose
Downloading ruby-3.2.2.tar.gz...
-> https://cache.ruby-lang.org/pub/ruby/3.2/ruby-3.2.2.tar.gz
Installing ruby-3.2.2...
Installed ruby-3.2.2 to /root/.rbenv/versions/3.2.2
```bash

## まとめ(感想文)

ビルドする前に知りたいー。