kmjooh
@kmjooh (Masayuki Kamijo)

Are you sure you want to delete the question?

Leaving a resolved question undeleted may help others!

【bundle installエラー】Ruby on Rails

解決したいこと

Ruby on Railsでプロジェクト作成時にbundle installができません。
解決方法を教えて下さい。

発生している問題・エラー

$ rails _5.2.2_ new vegerecipes --database=mysql --skip-test --skip-active-storage

とプロジェクト作成しようとすると

Installing mysql2 0.5.3 with native extensions
Gem::Ext::BuildError: ERROR: Failed to build gem native extension.

    current directory: /home/ec2-user/.rvm/gems/ruby-2.6.3/gems/mysql2-0.5.3/ext/mysql2
/home/ec2-user/.rvm/rubies/ruby-2.6.3/bin/ruby -I /home/ec2-user/.rvm/rubies/ruby-2.6.3/lib/ruby/site_ruby/2.6.0 -r
./siteconf20210103-19636-1g6lkz3.rb extconf.rb
checking for rb_absint_size()... yes
checking for rb_absint_singlebit_p()... yes
checking for rb_wait_for_single_fd()... yes
checking for -lmysqlclient... yes
checking for mysql.h... no
checking for mysql/mysql.h... no
-----
mysql.h is missing. You may need to 'sudo apt-get install libmariadb-dev', 'sudo apt-get install libmysqlclient-dev' or 'sudo yum install
mysql-devel', and try again.
-----
*** 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
        --without-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=/home/ec2-user/.rvm/rubies/ruby-2.6.3/bin/$(RUBY_BASE_NAME)
        --with-mysql-dir
        --without-mysql-dir
        --with-mysql-include
        --without-mysql-include=${mysql-dir}/include
        --with-mysql-lib
        --without-mysql-lib=${mysql-dir}/lib
        --with-mysql-config
        --without-mysql-config
        --with-mysql-dir
        --without-mysql-dir
        --with-mysql-include
        --without-mysql-include=${mysql-dir}/include
        --with-mysql-lib
        --without-mysql-lib=${mysql-dir}/lib
        --with-mysqlclientlib
        --without-mysqlclientlib

To see why this extension failed to compile, please check the mkmf.log which can be found here:

  /home/ec2-user/.rvm/gems/ruby-2.6.3/extensions/x86_64-linux/2.6.0/mysql2-0.5.3/mkmf.log

extconf failed, exit code 1

Gem files will remain installed in /home/ec2-user/.rvm/gems/ruby-2.6.3/gems/mysql2-0.5.3 for inspection.
Results logged to /home/ec2-user/.rvm/gems/ruby-2.6.3/extensions/x86_64-linux/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
         run  bundle exec spring binstub --all
bundler: command not found: spring
Install missing gem executables with `bundle install`

と表示され、bundle installが上手くいっていないようです。 

自分で試したこと

$ gem install mysql2 -v '0.5.3' --source 'https://rubygems.org/

とやってみましたが、

Building native extensions. This could take a while...
ERROR:  Error installing mysql2:
        ERROR: Failed to build gem native extension.

と表示されました。

解決方法をご教示おねがいします。

0

2Answer

Comments

  1. @kmjooh

    Questioner

    回答ありがとうございます!
    試してみましたが、上手くいきませんでした。もう少し幅広く調べてみます。

Comments

  1. @kmjooh

    Questioner

    ありがとうございます!解決しました。

Your answer might help someone💌