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?

mysql2 rails インストール時のエラー対応と同様にnio4rのインストールエラーで悩まされたので書き記す

Last updated at Posted at 2024-12-28

rails7⇔rails5を行ったり来たりしていると、、rails5のbundleでnio4r(IO周りのライブラリ)が入らなくなってめちゃくちゃ悩まされたので、記載しておきます

みなさんmysql2のインストールで苦戦すると思うのですが(しませんか?)今回はnio4rがめちゃくちゃ苦戦を強いてきました。。。。。

【結論】

下記記事と一緒で--with-cflags=-Wno-incompatible-pointer-typesをたすのですが、、それだけだとどうもうまく行かず、

--with-cppflags=-I/opt/homebrew/opt/openssl@1.1/include --with-ldflags=-L/opt/homebrew/opt/openssl@1.1/lib
も入れてインストールしました。(mysql2のときにいれるオプションです)

bundle configは一度は確認画面に入るので、二回実施すると設定が入るみたいです。

bundle config --local build.nio4r "--with-cppflags=-I/opt/homebrew/opt/openssl@1.1/include --with-ldflags=-L/opt/homebrew/opt/openssl@1.1/lib --with-cflags=-Wno-incompatible-pointer-types"

【色々試行錯誤】
opensslは2024/11から非推奨になったopenssl1に敢えて落としました。
openssl3でやっても多分うまくいくかと。。(未実験)
xcodeも入れ直したりしましたが、これはおそらく無関係です。
( xcode-select --install)

【遭遇したエラーログ】

Installing nio4r 2.3.1 with native extensions
Gem::Ext::BuildError: ERROR: Failed to build gem native extension.

    current directory: /private/var/folders/l1/_rfqwsqj04538zdhhdhhz8tc0000gn/T/bundler20241228-21142-umjgmhnio4r-2.3.1/gems/nio4r-2.3.1/ext/nio4r
/Users/shirotabuchi/.rbenv/versions/2.6.9/bin/ruby -I /Users/shirotabuchi/.rbenv/versions/2.6.9/lib/ruby/2.6.0 -r ./siteconf20241228-21142-102l9ow.rb extconf.rb
--with-cppflags\=-I/opt/homebrew/opt/openssl@1.1/include --with-ldflags\=-L/opt/homebrew/opt/openssl@1.1/lib
checking for unistd.h... yes
checking for sys/select.h... yes
checking for port_event_t in poll.h... no
checking for sys/epoll.h... no
checking for sys/event.h... yes
checking for sys/queue.h... yes
checking for port_event_t in port.h... no
checking for sys/resource.h... yes
creating Makefile

current directory: /private/var/folders/l1/_rfqwsqj04538zdhhdhhz8tc0000gn/T/bundler20241228-21142-umjgmhnio4r-2.3.1/gems/nio4r-2.3.1/ext/nio4r
make "DESTDIR=" clean

current directory: /private/var/folders/l1/_rfqwsqj04538zdhhdhhz8tc0000gn/T/bundler20241228-21142-umjgmhnio4r-2.3.1/gems/nio4r-2.3.1/ext/nio4r
make "DESTDIR="
compiling bytebuffer.c
compiling monitor.c
monitor.c:87:24: warning: '(' and '{' tokens introducing statement expression appear in different macro expansion contexts [-Wcompound-token-split-by-macro]
   87 |     if(interests_id == rb_intern("r")) {
      |                        ^~~~~~~~~~~~~~
/Users/shirotabuchi/.rbenv/versions/2.6.9/include/ruby-2.6.0/ruby/ruby.h:1826:23: note: expanded from macro 'rb_intern'
 1826 |         __extension__ (RUBY_CONST_ID_CACHE((ID), (str))) : \
      |                       ^
monitor.c:87:24: note: '{' token is here
   87 |     if(interests_id == rb_intern("r")) {
      |                        ^~~~~~~~~~~~~~
/Users/shirotabuchi/.rbenv/versions/2.6.9/include/ruby-2.6.0/ruby/ruby.h:1826:24: note: expanded from macro 'rb_intern'
 1826 |         __extension__ (RUBY_CONST_ID_CACHE((ID), (str))) : \
      |                        ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/Users/shirotabuchi/.rbenv/versions/2.6.9/include/ruby-2.6.0/ruby/ruby.h:1811:5: note: expanded from macro 'RUBY_CONST_ID_CACHE'
 1811 |     {                                                   \
      |     ^
monitor.c:87:24: warning: '}' and ')' tokens terminating statement expression appear in different macro expansion contexts [-Wcompound-token-split-by-macro]
   87 |     if(interests_id == rb_intern("r")) {
      |                        ^~~~~~~~~~~~~~
/Users/shirotabuchi/.rbenv/versions/2.6.9/include/ruby-2.6.0/ruby/ruby.h:1826:24: note: expanded from macro 'rb_intern'
 1826 |         __extension__ (RUBY_CONST_ID_CACHE((ID), (str))) : \
      |                        ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/Users/shirotabuchi/.rbenv/versions/2.6.9/include/ruby-2.6.0/ruby/ruby.h:1816:5: note: expanded from macro 'RUBY_CONST_ID_CACHE'
 1816 |     }
      |     ^
monitor.c:87:24: note: ')' token is here
   87 |     if(interests_id == rb_intern("r")) {
      |                        ^~~~~~~~~~~~~~
/Users/shirotabuchi/.rbenv/versions/2.6.9/include/ruby-2.6.0/ruby/ruby.h:1826:56: note: expanded from macro 'rb_intern'
 1826 |         __extension__ (RUBY_CONST_ID_CACHE((ID), (str))) : \
      |                                                        ^
monitor.c:89:31: warning: '(' and '{' tokens introducing statement expression appear in different macro expansion contexts [-Wcompound-token-split-by-macro]
   89 |     } else if(interests_id == rb_intern("w")) {
      |                               ^~~~~~~~~~~~~~
/Users/shirotabuchi/.rbenv/versions/2.6.9/include/ruby-2.6.0/ruby/ruby.h:1826:23: note: expanded from macro 'rb_intern'
 1826 |         __extension__ (RUBY_CONST_ID_CACHE((ID), (str))) : \
      |                       ^
monitor.c:89:31: note: '{' token is here
   89 |     } else if(interests_id == rb_intern("w")) {
      |                               ^~~~~~~~~~~~~~
/Users/shirotabuchi/.rbenv/versions/2.6.9/include/ruby-2.6.0/ruby/ruby.h:1826:24: note: expanded from macro 'rb_intern'
 1826 |         __extension__ (RUBY_CONST_ID_CACHE((ID), (str))) : \
      |                        ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/Users/shirotabuchi/.rbenv/versions/2.6.9/include/ruby-2.6.0/ruby/ruby.h:1811:5: note: expanded from macro 'RUBY_CONST_ID_CACHE'
 1811 |     {                                                   \
      |     ^
monitor.c:89:31: warning: '}' and ')' tokens terminating statement expression appear in different macro expansion contexts [-Wcompound-token-split-by-macro]
   89 |     } else if(interests_id == rb_intern("w")) {
      |                               ^~~~~~~~~~~~~~
/Users/shirotabuchi/.rbenv/versions/2.6.9/include/ruby-2.6.0/ruby/ruby.h:1826:24: note: expanded from macro 'rb_intern'
 1826 |         __extension__ (RUBY_CONST_ID_CACHE((ID), (str))) : \
      |                        ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/Users/shirotabuchi/.rbenv/versions/2.6.9/include/ruby-2.6.0/ruby/ruby.h:1816:5: note: expanded from macro 'RUBY_CONST_ID_CACHE'
 1816 |     }
      |     ^
monitor.c:89:31: note: ')' token is here
   89 |     } else if(interests_id == rb_intern("w")) {
      |                               ^~~~~~~~~~~~~~
/Users/shirotabuchi/.rbenv/versions/2.6.9/include/ruby-2.6.0/ruby/ruby.h:1826:56: note: expanded from macro 'rb_intern'
 1826 |         __extension__ (RUBY_CONST_ID_CACHE((ID), (str))) : \
      |                                                        ^
monitor.c:91:31: warning: '(' and '{' tokens introducing statement expression appear in different macro expansion contexts [-Wcompound-token-split-by-macro]
   91 |     } else if(interests_id == rb_intern("rw")) {
      |                               ^~~~~~~~~~~~~~~
/Users/shirotabuchi/.rbenv/versions/2.6.9/include/ruby-2.6.0/ruby/ruby.h:1826:23: note: expanded from macro 'rb_intern'
 1826 |         __extension__ (RUBY_CONST_ID_CACHE((ID), (str))) : \
      |                       ^
monitor.c:91:31: note: '{' token is here



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?