前提・実現したいこと
初めて質問させていただきます。情報の不足ないように記載するつもりですが、何か至らない点があればご指摘いただけるとたすかります。
macでrailsの環境構築中です。bunlde install を実施してもmysq2がインストールできずに進まない状況です。
似たような事象が起きている記事を、本サイトも含めて色々と試しましたが、解決できていません。
本当に困っています。何かご助言いただけると幸いです。
発生している問題・エラーメッセージ
rails new で作ったsample_appディレクトリ でbundle installを実施してもエラー
rails sもできない。
該当のソースコード
使用言語:Ruby
USERnoMacBook-Pro:sample_app user$ sudo bundle install
Password:
Don't run Bundler as root. Bundler can ask for sudo if it is needed, and installing your bundle as root will break this application for all non-root users on this machine.
Fetching gem metadata from https://rubygems.org/............
Resolving dependencies.....
Using rake 13.0.3
Using concurrent-ruby 1.1.8
Using erubi 1.10.0
Using thread_safe 0.3.6
Using minitest 5.14.4
Using racc 1.5.2
Using crass 1.0.6
Using rack 2.2.3
Using nio4r 2.5.7
Using websocket-extensions 0.1.5
Using mini_mime 1.1.0
Using arel 9.0.0
Using marcel 1.0.1
Using public_suffix 4.0.6
Using io-like 0.3.1
Using bindex 0.8.1
Using msgpack 1.4.2
Using bundler 2.2.15
Using byebug 11.1.3
Using regexp_parser 2.1.1
Using childprocess 3.0.0
Using coffee-script-source 1.12.2
Using execjs 2.7.0
Using method_source 1.0.0
Using thor 1.1.0
Using ffi 1.15.0
Using rb-fsevent 0.10.4
Using ruby_dep 1.5.0
Using puma 3.12.6
Using tilt 2.0.10
Using spring 2.1.1
Using turbolinks-source 5.2.0
Using i18n 1.8.10
Using tzinfo 1.2.9
Using rubyzip 2.3.0
Using nokogiri 1.11.2 (arm64-darwin)
Using rack-test 1.1.0
Using websocket-driver 0.7.3
Using nokogiri 1.11.2 (x86_64-darwin)
Using addressable 2.7.0
Fetching mysql2 0.5.3
Using builder 3.2.4
Using archive-zip 0.12.0
Using bootsnap 1.7.3
Using coffee-script 2.4.1
Using rb-inotify 0.10.1
Using sprockets 3.7.2
Using uglifier 4.2.0
Using turbolinks 5.2.1
Using activesupport 5.2.5
Using selenium-webdriver 3.142.7
Using loofah 2.9.0
Using xpath 3.2.0
Using mail 2.7.1
Using rails-dom-testing 2.0.3
Using activemodel 5.2.5
Using globalid 0.4.2
Using rails-html-sanitizer 1.3.0
Using capybara 3.35.3
Using listen 3.1.5
Using sass-listen 4.0.0
Using actionview 5.2.5
Using jbuilder 2.11.2
Using chromedriver-helper 2.1.1
Using activejob 5.2.5
Using activerecord 5.2.5
Using spring-watcher-listen 2.0.1
Using sass 3.7.4
Using actionpack 5.2.5
Using activestorage 5.2.5
Using railties 5.2.5
Using actionmailer 5.2.5
Using sprockets-rails 3.2.2
Using actioncable 5.2.5
Using coffee-rails 4.2.2
Using sass-rails 5.1.0
Using web-console 3.7.0
Using rails 5.2.5
Installing mysql2 0.5.3 with native extensions
Gem::Ext::BuildError: ERROR: Failed to build gem native extension.
current directory: /Library/Ruby/Gems/2.6.0/gems/mysql2-0.5.3/ext/mysql2
/System/Library/Frameworks/Ruby.framework/Versions/2.6/usr/bin/ruby -I /System/Library/Frameworks/Ruby.framework/Versions/2.6/usr/lib/ruby/2.6.0 -r ./siteconf20210405-31769-m7b75d.rb extconf.rb
--with-opt-dir=/usr/local/opt/openssl@1.1
checking for rb_absint_size()... *** extconf.rb failed ***
Could not create Makefile due to some reason, probably lack of necessary
libraries and/or headers. Check the mkmf.log file for more details. You may
need configuration options.
Provided configuration options:
--with-opt-dir
--with-opt-include
--without-opt-include=${opt-dir}/include
--with-opt-lib
--without-opt-lib=${opt-dir}/lib
--with-make-prog
--without-make-prog
--srcdir=.
--curdir
--ruby=/System/Library/Frameworks/Ruby.framework/Versions/2.6/usr/bin/$(RUBY_BASE_NAME)
/System/Library/Frameworks/Ruby.framework/Versions/2.6/usr/lib/ruby/2.6.0/mkmf.rb:467:in try_do': The compiler failed to generate an executable file. (RuntimeError) You have to install development tools first. from /System/Library/Frameworks/Ruby.framework/Versions/2.6/usr/lib/ruby/2.6.0/mkmf.rb:546:in
block in try_link0'
from /System/Library/Frameworks/Ruby.framework/Versions/2.6/usr/lib/ruby/2.6.0/tmpdir.rb:93:in mktmpdir' from /System/Library/Frameworks/Ruby.framework/Versions/2.6/usr/lib/ruby/2.6.0/mkmf.rb:543:in
try_link0'
from /System/Library/Frameworks/Ruby.framework/Versions/2.6/usr/lib/ruby/2.6.0/mkmf.rb:570:in try_link' from /System/Library/Frameworks/Ruby.framework/Versions/2.6/usr/lib/ruby/2.6.0/mkmf.rb:782:in
try_func'
from /System/Library/Frameworks/Ruby.framework/Versions/2.6/usr/lib/ruby/2.6.0/mkmf.rb:1069:in block in have_func' from /System/Library/Frameworks/Ruby.framework/Versions/2.6/usr/lib/ruby/2.6.0/mkmf.rb:959:in
block in checking_for'
from /System/Library/Frameworks/Ruby.framework/Versions/2.6/usr/lib/ruby/2.6.0/mkmf.rb:361:in block (2 levels) in postpone' from /System/Library/Frameworks/Ruby.framework/Versions/2.6/usr/lib/ruby/2.6.0/mkmf.rb:331:in
open'
from /System/Library/Frameworks/Ruby.framework/Versions/2.6/usr/lib/ruby/2.6.0/mkmf.rb:361:in block in postpone' from /System/Library/Frameworks/Ruby.framework/Versions/2.6/usr/lib/ruby/2.6.0/mkmf.rb:331:in
open'
from /System/Library/Frameworks/Ruby.framework/Versions/2.6/usr/lib/ruby/2.6.0/mkmf.rb:357:in postpone' from /System/Library/Frameworks/Ruby.framework/Versions/2.6/usr/lib/ruby/2.6.0/mkmf.rb:958:in
checking_for'
from /System/Library/Frameworks/Ruby.framework/Versions/2.6/usr/lib/ruby/2.6.0/mkmf.rb:1068:in have_func' from extconf.rb:25:in
<main>'
To see why this extension failed to compile, please check the mkmf.log which can be found here:
/Library/Ruby/Gems/2.6.0/extensions/universal-darwin-19/2.6.0/mysql2-0.5.3/mkmf.log
extconf failed, exit code 1
Gem files will remain installed in /Library/Ruby/Gems/2.6.0/gems/mysql2-0.5.3 for inspection.
Results logged to /Library/Ruby/Gems/2.6.0/extensions/universal-darwin-19/2.6.0/mysql2-0.5.3/gem_make.out
An error occurred while installing mysql2 (0.5.3), and Bundler cannot continue.
Make sure that gem install mysql2 -v '0.5.3' --source 'https://rubygems.org/'
succeeds before bundling.
In Gemfile:
mysql2
試したこと
gem install mysql2 -v '0.5.3' --source 'https://rubygems.org/'の実行
mkmf.logの確認
cat /Library/Ruby/Gems/2.6.0/extensions/universal-darwin-19/2.6.0/mysql2-0.5.3/mkmf.logで見に行く
mkmf.logの中身
"xcrun clang -o conftest -I/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX11.1.sdk/System/Library/Frameworks/Ruby.framework/Versions/2.6/usr/include/ruby-2.6.0/universal-darwin19 -I/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX11.1.sdk/System/Library/Frameworks/Ruby.framework/Versions/2.6/usr/include/ruby-2.6.0/ruby/backward -I/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX11.1.sdk/System/Library/Frameworks/Ruby.framework/Versions/2.6/usr/include/ruby-2.6.0 -I. -I/usr/local/opt/openssl@1.1/include -D_XOPEN_SOURCE -D_DARWIN_C_SOURCE -D_DARWIN_UNLIMITED_SELECT -D_REENTRANT -g -Os -pipe -DHAVE_GCC_ATOMIC_BUILTINS conftest.c -L. -L/System/Library/Frameworks/Ruby.framework/Versions/2.6/usr/lib -L/usr/local/opt/openssl@1.1/lib -L. -L/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.15.Internal.sdk/usr/local/lib -arch x86_64 -lruby.2.6 "
In file included from conftest.c:1:
In file included from /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX11.1.sdk/System/Library/Frameworks/Ruby.framework/Versions/2.6/usr/include/ruby-2.6.0/ruby.h:33:
/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX11.1.sdk/System/Library/Frameworks/Ruby.framework/Versions/2.6/usr/include/ruby-2.6.0/ruby/ruby.h:24:10: fatal error: 'ruby/config.h' file not found #include "ruby/config.h"
^~~~~~~~~~~~~~~
/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX11.1.sdk/System/Library/Frameworks/Ruby.framework/Versions/2.6/usr/include/ruby-2.6.0/ruby/ruby.h:24:10: note: did not find header 'config.h' in framework 'ruby' (loaded from '/Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/System/Library/Frameworks')
1 error generated.
checked program was:
/* begin */
1: #include "ruby.h"
2:
3: int main(int argc, char *argv)
4: {
5: return 0;
6: }
/ end */
**
中身は見れるもその後どうするべきかわからず。
補足情報(FW/ツールのバージョンなど)
実行環境
macOS Catalina
ruby 2.6.3
rbenv 1.1.2
$ which ruby
/usr/bin/ruby
gem 3.0.3
Xcode 12.4
Build version 12D4e
$ mysql --version
mysql Ver 8.0.23 for osx10.15 on x86_64 (Homebrew)
回答2件
あなたの回答
tips
プレビュー
バッドをするには、ログインかつ
こちらの条件を満たす必要があります。
2021/04/14 14:06
2021/04/14 14:18