0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

rbenv install 2.6.6でエラーが発生した

Posted at

はじめに

rbenvを使用してRuby 2.6.6をインストールする際に、さまざまな要因で失敗しました。
以下に私が試して有効だったものを列挙します。

あなたがOpenSSLの3系を使用している場合

以下コマンドでOpenSSLのバージョンを確認できます

% openssl version

Ruby 2.4〜3.0はOpenSSL 3系ではインストールできないので、OpenSSL@1.1.1系をインストールする必要があります。

brew install openssl@1.1ではインストールできないので、下記記事を参考にインストールしてください。

ffi_prep_closureによりビルドが失敗する場合

build logに下記の記述がある場合

closure.c:264:14: error: call to undeclared function 'ffi_prep_closure'; ISO C99 and later do not support implicit function declarations [-Wimplicit-function-declaration]
※build logの確認方法

インストールに失敗した際、下記のような出力になるかと思います。
出力の最後にSee the full build log at ~があるので、そこを見れば良いです。

$ rbenv install 2.6.6              
(略)
BUILD FAILED (macOS 13.7.4 on arm64 using ruby-build 20250215)

You can inspect the build directory at /var/folders/rs/〇〇
See the full build log at /var/folders/rs/〇〇 <- ここにbuild logがあります

インストール時に環境変数RUBY_CFLAGSを指定することで解決する

$ RUBY_CFLAGS=-DUSE_FFI_CLOSURE_ALLOC rbenv install 2.6.6

他の環境変数があっているか確認する

build logに以下のようなエラーがある場合、環境変数に設定しているパスが誤っている

(略)
ld: warning: search path '/opt/homebrew/opt/php@8.0/lib' not found
(略)

以下の手順で再設定

  1. 環境変数を確認

    % export -p
    (略)
    export LDFLAGS=-L/opt/homebrew/opt/php@8.0/lib
    (略)
    
  2. 削除

    $ unset LDFLAGS
    
  3. 設定

    $ export LDFLAGS=-L/opt/homebrew/opt/php@8.3/lib
    
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

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?