Techioz Blog

Big SurにRubyをインストールする方法

概要

私の MacBook Pro は古いため、私がアップデートできる最新のオペレーティング システムは Big Sur 11.7.2 です (これは、Apple Store のジーニアス バーが今日インストールしてくれた OS です)。新しい OS を入手した後、互換性のあるバージョンのコマンド ライン ツール (12.2) をインストールしました。さて、rbenv を使用して Ruby のいくつかのバージョンをインストールしようとしましたが、すべてビルドに失敗しました。

最新 (3.3.0) をインストールしようとすると、このエラーが発生しました。

/usr/local/lib/clang/5.0.0/include/inttypes.h:30:15: fatal error: 'inttypes.h' file not found
#include_next <inttypes.h>
              ^~~~~~~~~~~~
In file included from apps/lib/app_provider.c:10:
In file included from apps/include/apps.h:13:
In file included from include/internal/e_os.h:16:
In file included from include/openssl/e_os2.h:234:
/usr/local/lib/clang/5.0.0/include/inttypes.h:30:15: fatal error: 'inttypes.h' file not found
#include_next <inttypes.h>
              ^~~~~~~~~~~~
In file included from apps/lib/app_params.c:10:
In file included from apps/include/apps.h:13:
In file included from include/internal/e_os.h:16:
In file included from include/openssl/e_os2.h:234:
/usr/local/lib/clang/5.0.0/include/inttypes.h:30:15: fatal error: 'inttypes.h' file not found
#include_next <inttypes.h>
              ^~~~~~~~~~~~
In file included from apps/lib/app_rand.c:10:
In file included from apps/include/apps.h:13:
In file included from include/internal/e_os.h:16:
In file included from include/openssl/e_os2.h:234:
/usr/local/lib/clang/5.0.0/include/inttypes.h:30:15: fatal error: 'inttypes.h' file not found
#include_next <inttypes.h>

OS とコマンド ライン ツールのリリースに基づいて互換性があると思われるバージョン (2.7.2) をインストールしようとすると、次のエラーが発生します。

apps/bf_prefix.c:10:10: fatal error: 'stdio.h' file not found
#include <stdio.h>
         ^~~~~~~~~
apps/apps.c:18:10: fatal error: 'stdio.h' file not found
#include <stdio.h>
         ^~~~~~~~~
In file included from apps/app_rand.c:10:
In file included from apps/apps.h:13:
In file included from ./e_os.h:16:
In file included from include/openssl/e_os2.h:243:
/usr/local/lib/clang/5.0.0/include/inttypes.h:30:15: fatal error: 'inttypes.h' file not found
#include_next <inttypes.h>
              ^~~~~~~~~~~~
In file included from apps/opt.c:9:
In file included from apps/apps.h:13:
In file included from ./e_os.h:16:
In file included from include/openssl/e_os2.h:243:
/usr/local/lib/clang/5.0.0/include/inttypes.h:30:15: fatal error: 'inttypes.h' file not found
#include_next <inttypes.h>

私のバージョンのclang

clang version 5.0.0 (trunk 300079)
Target: x86_64-apple-darwin20.6.0
Thread model: posix
InstalledDir: /usr/local/bin

システムに付属しているもの以外のより新しいバージョンの Ruby をインストールするにはどうすればよいですか?

ruby 2.6.10p210 (2022-04-12 revision 67958) [universal.x86_64-darwin20]

アップデート

Ruby 3.3.0 をインストールするための完全な rbenv ログ

rbenv install 3.3.0
==> Downloading openssl-3.1.4.tar.gz...
-> curl -q -fL -o openssl-3.1.4.tar.gz https://dqw8nmjcqpjn7.cloudfront.net/840af5366ab9b522bde525826be3ef0fb0af81c6a9ebd84caa600fea1731eee3
  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed
100 14.8M  100 14.8M    0     0  25.7M      0 --:--:-- --:--:-- --:--:-- 25.7M
==> Installing openssl-3.1.4...
-> ./config "--prefix=$HOME/.rbenv/versions/3.3.0/openssl" "--openssldir=$HOME/.rbenv/versions/3.3.0/openssl/ssl" zlib-dynamic no-ssl3 shared
-> make -j 4

BUILD FAILED (macOS 11.7.2 on x86_64 using ruby-build 20240119-2-g28d59ac)

You can inspect the build directory at /var/folders/5y/wtzzmjlj5v52pg7wr8ptbg_m0000gp/T/ruby-build.20240220103938.12604.Ma5Elp
See the full build log at /var/folders/5y/wtzzmjlj5v52pg7wr8ptbg_m0000gp/T/ruby-build.20240220103938.12604.log
Michaels-MacBook-Pro-3:~ mm$ cat /var/folders/5y/wtzzmjlj5v52pg7wr8ptbg_m0000gp/T/ruby-build.20240220103938.12604.log
cd /var/folders/5y/wtzzmjlj5v52pg7wr8ptbg_m0000gp/T/ruby-build.20240220103938.12604.Ma5Elp
==> Downloading openssl-3.1.4.tar.gz...
-> curl -q -fL -o openssl-3.1.4.tar.gz https://dqw8nmjcqpjn7.cloudfront.net/840af5366ab9b522bde525826be3ef0fb0af81c6a9ebd84caa600fea1731eee3
-> tar xzf openssl-3.1.4.tar.gz
cd /var/folders/5y/wtzzmjlj5v52pg7wr8ptbg_m0000gp/T/ruby-build.20240220103938.12604.Ma5Elp/openssl-3.1.4
==> Installing openssl-3.1.4...
-> ./config "--prefix=$HOME/.rbenv/versions/3.3.0/openssl" "--openssldir=$HOME/.rbenv/versions/3.3.0/openssl/ssl" zlib-dynamic no-ssl3 shared
Configuring OpenSSL version 3.1.4 for target darwin64-x86_64
Using os-specific seed configuration
Created configdata.pm
Running configdata.pm
Created Makefile.in
Created Makefile
Created include/openssl/configuration.h

**********************************************************************
***                                                                ***
***   OpenSSL has been successfully configured                     ***
***                                                                ***
***   If you encounter a problem while building, please open an    ***
***   issue on GitHub <https://github.com/openssl/openssl/issues>  ***
***   and include the output from the following command:           ***
***                                                                ***
***       perl configdata.pm --dump                                ***
***                                                                ***
***   (If you are new to OpenSSL, you might want to consult the    ***
***   'Troubleshooting' section in the INSTALL.md file first)      ***
***                                                                ***
**********************************************************************
-> make -j 4
perl "-I." -Mconfigdata "util/dofile.pl" "-oMakefile" include/crypto/bn_conf.h.in > include/crypto/bn_conf.h
perl "-I." -Mconfigdata "util/dofile.pl" "-oMakefile" include/crypto/dso_conf.h.in > include/crypto/dso_conf.h
perl "-I." -Mconfigdata "util/dofile.pl" "-oMakefile" include/openssl/asn1.h.in > include/openssl/asn1.h
perl "-I." -Mconfigdata "util/dofile.pl" "-oMakefile" include/openssl/asn1t.h.in > include/openssl/asn1t.h
perl "-I." -Mconfigdata "util/dofile.pl" "-oMakefile" include/openssl/bio.h.in > include/openssl/bio.h
perl "-I." -Mconfigdata "util/dofile.pl" "-oMakefile" include/openssl/cmp.h.in > include/openssl/cmp.h
perl "-I." -Mconfigdata "util/dofile.pl" "-oMakefile" include/openssl/cms.h.in > include/openssl/cms.h
perl "-I." -Mconfigdata "util/dofile.pl" "-oMakefile" include/openssl/conf.h.in > include/openssl/conf.h
perl "-I." -Mconfigdata "util/dofile.pl" "-oMakefile" include/openssl/crmf.h.in > include/openssl/crmf.h
perl "-I." -Mconfigdata "util/dofile.pl" "-oMakefile" include/openssl/crypto.h.in > include/openssl/crypto.h
perl "-I." -Mconfigdata "util/dofile.pl" "-oMakefile" include/openssl/ct.h.in > include/openssl/ct.h
perl "-I." -Mconfigdata "util/dofile.pl" "-oMakefile" include/openssl/err.h.in > include/openssl/err.h
perl "-I." -Mconfigdata "util/dofile.pl" "-oMakefile" include/openssl/ess.h.in > include/openssl/ess.h
perl "-I." -Mconfigdata "util/dofile.pl" "-oMakefile" include/openssl/fipskey.h.in > include/openssl/fipskey.h
perl "-I." -Mconfigdata "util/dofile.pl" "-oMakefile" include/openssl/lhash.h.in > include/openssl/lhash.h
perl "-I." -Mconfigdata "util/dofile.pl" "-oMakefile" include/openssl/ocsp.h.in > include/openssl/ocsp.h
perl "-I." -Mconfigdata "util/dofile.pl" "-oMakefile" include/openssl/opensslv.h.in > include/openssl/opensslv.h
perl "-I." -Mconfigdata "util/dofile.pl" "-oMakefile" include/openssl/pkcs12.h.in > include/openssl/pkcs12.h
perl "-I." -Mconfigdata "util/dofile.pl" "-oMakefile" include/openssl/pkcs7.h.in > include/openssl/pkcs7.h
perl "-I." -Mconfigdata "util/dofile.pl" "-oMakefile" include/openssl/safestack.h.in > include/openssl/safestack.h
perl "-I." -Mconfigdata "util/dofile.pl" "-oMakefile" include/openssl/srp.h.in > include/openssl/srp.h
perl "-I." -Mconfigdata "util/dofile.pl" "-oMakefile" include/openssl/ssl.h.in > include/openssl/ssl.h
perl "-I." -Mconfigdata "util/dofile.pl" "-oMakefile" include/openssl/ui.h.in > include/openssl/ui.h
perl "-I." -Mconfigdata "util/dofile.pl" "-oMakefile" include/openssl/x509.h.in > include/openssl/x509.h
perl "-I." -Mconfigdata "util/dofile.pl" "-oMakefile" include/openssl/x509_vfy.h.in > include/openssl/x509_vfy.h
perl "-I." -Mconfigdata "util/dofile.pl" "-oMakefile" include/openssl/x509v3.h.in > include/openssl/x509v3.h
perl "-I." -Mconfigdata "util/dofile.pl" "-oMakefile" test/provider_internal_test.cnf.in > test/provider_internal_test.cnf
make depend && make _build_sw
clang  -I. -Iinclude -Iapps/include  -fPIC -arch x86_64 -O3 -Wall -DL_ENDIAN -DOPENSSL_PIC -DOPENSSLDIR="\"/Users/mm/.rbenv/versions/3.3.0/openssl/ssl\"" -DENGINESDIR="\"/Users/mm/.rbenv/versions/3.3.0/openssl/lib/engines-3\"" -DMODULESDIR="\"/Users/mm/.rbenv/versions/3.3.0/openssl/lib/ossl-modules\"" -D_REENTRANT -DOPENSSL_BUILDING_OPENSSL -DZLIB -DZLIB_SHARED -DNDEBUG  -MMD -MF apps/lib/libapps-lib-app_libctx.d.tmp -MT apps/lib/libapps-lib-app_libctx.o -c -o apps/lib/libapps-lib-app_libctx.o apps/lib/app_libctx.c
clang  -I. -Iinclude -Iapps/include  -fPIC -arch x86_64 -O3 -Wall -DL_ENDIAN -DOPENSSL_PIC -DOPENSSLDIR="\"/Users/mm/.rbenv/versions/3.3.0/openssl/ssl\"" -DENGINESDIR="\"/Users/mm/.rbenv/versions/3.3.0/openssl/lib/engines-3\"" -DMODULESDIR="\"/Users/mm/.rbenv/versions/3.3.0/openssl/lib/ossl-modules\"" -D_REENTRANT -DOPENSSL_BUILDING_OPENSSL -DZLIB -DZLIB_SHARED -DNDEBUG  -MMD -MF apps/lib/libapps-lib-app_params.d.tmp -MT apps/lib/libapps-lib-app_params.o -c -o apps/lib/libapps-lib-app_params.o apps/lib/app_params.c
clang  -I. -Iinclude -Iapps/include  -fPIC -arch x86_64 -O3 -Wall -DL_ENDIAN -DOPENSSL_PIC -DOPENSSLDIR="\"/Users/mm/.rbenv/versions/3.3.0/openssl/ssl\"" -DENGINESDIR="\"/Users/mm/.rbenv/versions/3.3.0/openssl/lib/engines-3\"" -DMODULESDIR="\"/Users/mm/.rbenv/versions/3.3.0/openssl/lib/ossl-modules\"" -D_REENTRANT -DOPENSSL_BUILDING_OPENSSL -DZLIB -DZLIB_SHARED -DNDEBUG  -MMD -MF apps/lib/libapps-lib-app_provider.d.tmp -MT apps/lib/libapps-lib-app_provider.o -c -o apps/lib/libapps-lib-app_provider.o apps/lib/app_provider.c
clang  -I. -Iinclude -Iapps/include  -fPIC -arch x86_64 -O3 -Wall -DL_ENDIAN -DOPENSSL_PIC -DOPENSSLDIR="\"/Users/mm/.rbenv/versions/3.3.0/openssl/ssl\"" -DENGINESDIR="\"/Users/mm/.rbenv/versions/3.3.0/openssl/lib/engines-3\"" -DMODULESDIR="\"/Users/mm/.rbenv/versions/3.3.0/openssl/lib/ossl-modules\"" -D_REENTRANT -DOPENSSL_BUILDING_OPENSSL -DZLIB -DZLIB_SHARED -DNDEBUG  -MMD -MF apps/lib/libapps-lib-app_rand.d.tmp -MT apps/lib/libapps-lib-app_rand.o -c -o apps/lib/libapps-lib-app_rand.o apps/lib/app_rand.c
In file included from apps/lib/app_libctx.c:9:
In file included from apps/include/app_libctx.h:13:
In file included from include/openssl/types.h:32:
In file included from include/openssl/e_os2.h:234:
In file included from /usr/local/lib/clang/5.0.0/include/inttypes.h:30:15: fatal error: 'inttypes.h' file not found
#include_next <inttypes.h>
              ^~~~~~~~~~~~
apps/lib/app_provider.c:10:
In file included from apps/include/apps.h:13:
In file included from include/internal/e_os.h:16:
In file included from include/openssl/e_os2.h:234:
/usr/local/lib/clang/5.0.0/include/inttypes.h:30:15: fatal error: 'inttypes.h' file not found
#include_next <inttypes.h>
              ^~~~~~~~~~~~
In file included from apps/lib/app_rand.c:10:
In file included from apps/include/apps.h:13:
In file included from include/internal/e_os.h:16:
In file included from include/openssl/e_os2.h:234:
/usr/local/lib/clang/5.0.0/include/inttypes.h:30:15: fatal error: 'inttypes.h' file not found
#include_next <inttypes.h>
              ^~~~~~~~~~~~
In file included from apps/lib/app_params.c:10:
In file included from apps/include/apps.h:13:
In file included from include/internal/e_os.h:16:
In file included from include/openssl/e_os2.h:234:
/usr/local/lib/clang/5.0.0/include/inttypes.h:30:15: fatal error: 'inttypes.h' file not found
#include_next <inttypes.h>
              ^~~~~~~~~~~~
1 error generated.
1 error generated.
make[1]: *** [apps/lib/libapps-lib-app_params.o] Error 1
make[1]: *** Waiting for unfinished jobs....
make[1]: *** [apps/lib/libapps-lib-app_provider.o] Error 1
1 error generated.
1 error generated.
make[1]: *** [apps/lib/libapps-lib-app_rand.o] Error 1
make[1]: *** [apps/lib/libapps-lib-app_libctx.o] Error 1
make: *** [build_sw] Error 2
external command failed with status 2

解決策

通常、この種のエラーは、依存関係が欠落している場合に発生します。 Ruby をインストールする前に、最新の Xcode コマンド ライン ツールがインストールされていることを確認してください。

次のコマンドを使用して更新できます。

xcode-select –install