Help us understand the problem. What is going on with this article?

Macでrbenvが使えない!【binutilsの悪夢シリーズ】

以下のことがしたかった

  • rbenvでruby 2.6.5をインストール
  • 結論としては,binutilsが色々と悪さをする

環境

  • Mac Catalina 10.15.1

普通に入れようとした記録

$ brew install rbenv
... 略
$ rbenv install 2.6.5
Downloading openssl-1.1.1d.tar.gz...
-> https://dqw8nmjcqpjn7.cloudfront.net/1e3a91bc1f9dfce01af26026f856e064eab4c8ee0a8f457b5ae30b40b8b711f2
Installing openssl-1.1.1d...

BUILD FAILED (OS X 10.15.1 using ruby-build 20191124)

Inspect or clean up the working tree at /var/folders/df/0q1vdcy17j32kzq9xlb5zgg40000gn/T/ruby-build.20191203170740.4037.sKb82m
Results logged to /var/folders/df/0q1vdcy17j32kzq9xlb5zgg40000gn/T/ruby-build.20191203170740.4037.log

Last 10 log lines:
      _s_server_main in s_server.o
  "_verify_stateless_cookie_callback", referenced from:
      _s_server_main in s_server.o
  "_wait_for_async", referenced from:
      _s_client_main in s_client.o
      _sv_body in s_server.o
ld: symbol(s) not found for architecture x86_64
clang: error: linker command failed with exit code 1 (use -v to see invocation)
make[1]: *** [apps/openssl] Error 1
make: *** [all] Error 2

はて,Rubyを入れる前のOpenSSLのビルドでコケているみたいだ...

解決策

ログが /var/folders/df/0q1vdcy17j32kzq9xlb5zgg40000gn/T/ruby-build.20191203170740.4037.log にあるようなので覗いてみる

${LDCMD:-clang} -arch x86_64 -O3 -Wall -L. -Wl,-search_paths_first -L/Users/hiragi/.rbenv/versions/2.6.5/lib \
                -o apps/openssl apps/asn1pars.o apps/ca.o apps/ciphers.o apps/cms.o apps/crl.o apps/crl2p7.o apps/dgst.o apps/dhparam.o apps/dsa.o apps/dsaparam.o apps/ec.o apps/ecparam.o apps/enc.o apps/engine.o apps/errstr.o apps/gendsa.o apps/genpkey.o apps/genrsa.o apps/nseq.o apps/ocsp.o apps/openssl.o apps/passwd.o apps/pkcs12.o apps/pkcs7.o apps/pkcs8.o apps/pkey.o apps/pkeyparam.o apps/pkeyutl.o apps/prime.o apps/rand.o apps/rehash.o apps/req.o apps/rsa.o apps/rsautl.o apps/s_client.o apps/s_server.o apps/s_time.o apps/sess_id.o apps/smime.o apps/speed.o apps/spkac.o apps/srp.o apps/storeutl.o apps/ts.o apps/verify.o apps/version.o apps/x509.o \
                 apps/libapps.a -lssl -lcrypto  
ld: warning: directory not found for option '-L/Users/hiragi/.rbenv/versions/2.6.5/lib'
ld: warning: ignoring file apps/libapps.a, building for macOS-x86_64 but attempting to link with file built for unknown-unsupported file format ( 0x21 0x3C 0x61 0x72 0x63 0x68 0x3E 0x0A 0x2F 0x20 0x20 0x20 0x20 0x20 0x20 0x20 )
Undefined symbols for architecture x86_64:

#{LDCMD:-clang} はたぶんldのこと,コンパイルはちゃんと通ってるけど,リンクするときにうまく行っていない.
で,apps/libapps.a とかいう多分shared-library的なもののフォーマットが合っていないといった旨のエラー.

それともうちょっと上側を見てみると,

ar: creating libcrypto.a
ranlib -c libcrypto.a || echo Never mind.
ranlib: invalid option -- c

invalid option -- cて...なんか別のコマンドが実行されている...?

ranlib error とかでググってみると,以下のページが出た

https://tetsuok.hatenablog.com/entry/2012/05/07/054356

なるほど,なんかOS標準のarranlibを使わないとなにか別のものができてしまう模様...
そして更に調べると

https://naoyat.hatenablog.jp/entry/2012/01/31/033312

こんな記事も見つけた,どうやらbrewのbinutilsを入れていると,そいつの依存でついてくるarranlibが勝手にパスを通してしまうらしい.... こんなのわかるわけ無いやろ(半ギレ)
そういえば以前もなにか自前でビルドしようとしたときになんとなくbinutilsを消していた気がする...恐るべしbinutils....

https://qiita.com/nagomiso/items/dc6021beb72d09f2128f
似たような記事がありました,ただ原因と問題が発生する場所が違いすぎて原因にたどり着きにくい...
本格的にLinuxを動かすことを検討しないと,こういう問題が起きる毎に無駄に時間を使ってしまう.

Why not register and get more from Qiita?
  1. We will deliver articles that match you
    By following users and tags, you can catch up information on technical fields that you are interested in as a whole
  2. you can read useful information later efficiently
    By "stocking" the articles you like, you can search right away
Comments
No comments
Sign up for free and join this conversation.
If you already have a Qiita account
Why do not you register as a user and use Qiita more conveniently?
You need to log in to use this function. Qiita can be used more conveniently after logging in.
You seem to be reading articles frequently this month. Qiita can be used more conveniently after logging in.
  1. We will deliver articles that match you
    By following users and tags, you can catch up information on technical fields that you are interested in as a whole
  2. you can read useful information later efficiently
    By "stocking" the articles you like, you can search right away
ユーザーは見つかりませんでした