LoginSignup
25
31

More than 5 years have passed since last update.

bundleでnative extensionを使ったgemのインストールでエラーになる件 まとめ

Last updated at Posted at 2014-04-13

概要

bundleでgemをインストールする際に、いっつも同じgemで同じエラーが発生してググるはめになるのでまとめておくことにしました。

環境

  • Linux Mint 16 Petra (Ubuntu系)
  • rbenv 0.4.0-95-gf71e227
  • Ruby 2.1.1p76
  • Bundler 1.6.1

内容

mysql2

エラー内容

Gem::Ext::BuildError: ERROR: Failed to build gem native extension.

    /home/xxx/.rbenv/versions/2.1.1/bin/ruby extconf.rb 
checking for ruby/thread.h... yes
checking for rb_thread_call_without_gvl() in ruby/thread.h... yes
checking for rb_thread_blocking_region()... yes
checking for rb_wait_for_single_fd()... yes
checking for rb_hash_dup()... yes
checking for rb_intern3()... yes
checking for mysql_query() in -lmysqlclient... no

対応

sudo aptitude install libmysqld-dev

rmagick

エラー内容

Gem::Ext::BuildError: ERROR: Failed to build gem native extension.

    /home/xxx/.rbenv/versions/2.1.1/bin/ruby extconf.rb 
checking for Ruby version >= 1.8.5... yes
checking for gcc... yes
checking for Magick-config... no

対応

sudo aptitude install libmagickwand-dev

sqlite3

エラー内容

Gem::Ext::BuildError: ERROR: Failed to build gem native extension.

    /home/xxx/.rbenv/versions/2.1.1/bin/ruby extconf.rb 
checking for sqlite3.h... no

対応

sudo aptitude install libsqlite3-dev

最後はおまけ。
bundle installがとおった、ふーやれやれ。。。
と思ってrakeを実行するとエラーになる。

bundle exec rake db:migrate
rake aborted!
Could not find a JavaScript runtime. See https://github.com/sstephenson/execjs for a list of available runtimes.

Ubuntuにはjavascript runtimeがデフォルトで入っていない。nodejsをインストールするのがお手軽。

sudo aptitude install nodejs

gemでtherubyracerをインストールする方法もあるのですが、Macを使っている人がエラーになったりするので止めました。

以上。
これで毎回同じことを調べなくて済むはず!

25
31
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
25
31