2
2

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

bundle install で エラーがでました。

Last updated at Posted at 2016-01-08

rails sするために bundle installしたらエラーがでました。環境はVagrantでもともとCentOS6でやっていたものをCentOS7のboxに変更したものです。

Mysqlがない問題

bundle instal

略

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

    /home/vagrant/.rbenv/versions/2.2.4/bin/ruby -r ./siteconf20160108-4279-qe05qo.rb 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()... no
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
checking for main() in -lm... yes
checking for mysql_query() in -lmysqlclient... no
checking for main() in -lz... yes
checking for mysql_query() in -lmysqlclient... no
checking for main() in -lsocket... no
checking for mysql_query() in -lmysqlclient... no
checking for main() in -lnsl... yes
checking for mysql_query() in -lmysqlclient... no
checking for main() in -lmygcc... no
checking for mysql_query() in -lmysqlclient... no
*** 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.
```
mysql-develをyumからinstallします。

```
sudo yum install mysql-devel gcc make

略

=====================================================================================================================================
 Package                          アーキテクチャー          バージョン                                 リポジトリー             容量
=====================================================================================================================================
インストール中:
 mariadb-devel                    x86_64                    1:5.5.44-2.el7.centos                      base                    748 k
依存性関連でのインストールをします:
 mariadb-libs                     x86_64                    1:5.5.44-2.el7.centos                      base                    754 k

トランザクションの要約
=====================================================================================================================================
インストール  1 パッケージ (+1 個の依存関係のパッケージ)

総ダウンロード容量: 1.5 M
インストール容量: 7.7 M
Is this ok [y/d/N]: y

略
```
あとこれも

```
sudo yum install mysql mysql-server
```

mariadbになっちゃうけど良いのかな?

# pgがない問題

```
bundle install

略

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

    /home/vagrant/.rbenv/versions/2.2.4/bin/ruby -r ./siteconf20160108-4682-1jn9h2s.rb extconf.rb
checking for pg_config... no
No pg_config... trying anyway. If building fails, please try again with
 --with-pg-config=/path/to/pg_config
checking for libpq-fe.h... no
Can't find the 'libpq-fe.h header
*** 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.

略
```

pgをインストール

```
sudo yum install postgresql-devel

略
=====================================================================================================================================
 Package                             アーキテクチャー          バージョン                           リポジトリー                容量
=====================================================================================================================================
インストール中:
 postgresql-devel                    x86_64                    9.2.14-1.el7_1                       updates                    948 k
依存性関連でのインストールをします:
 postgresql                          x86_64                    9.2.14-1.el7_1                       updates                    3.0 M
 postgresql-libs                     x86_64                    9.2.14-1.el7_1                       updates                    231 k

トランザクションの要約
=====================================================================================================================================
インストール  1 パッケージ (+2 個の依存関係のパッケージ)

総ダウンロード容量: 4.1 M
インストール容量: 20 M
Is this ok [y/d/N]: y
略
```
pgがインストールされました。

```
bundle install

略

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

    /home/vagrant/.rbenv/versions/2.2.4/bin/ruby -r ./siteconf20160108-5365-lu62gx.rb extconf.rb
checking if the C compiler accepts ... yes
Building nokogiri using packaged libraries.
checking for gzdopen() in -lz... yes
checking for iconv... yes
************************************************************************
IMPORTANT NOTICE:

Building Nokogiri with a packaged version of libxml2-2.9.2
with the following patches applied:
	- 0001-Revert-Missing-initialization-for-the-catalog-module.patch
	- 0002-Fix-missing-entities-after-CVE-2014-3660-fix.patch

Team Nokogiri will keep on doing their best to provide security
updates in a timely manner, but if this is a concern for you and want
to use the system library instead; abort this installation process and
reinstall nokogiri as follows:

    gem install nokogiri -- --use-system-libraries
        [--with-xml2-config=/path/to/xml2-config]
        [--with-xslt-config=/path/to/xslt-config]

If you are using Bundler, tell it to use the option:

    bundle config build.nokogiri --use-system-libraries
    bundle install

Note, however, that nokogiri is not fully compatible with arbitrary
versions of libxml2 provided by OS/package vendors.

略
```
ここで `bundle config build.nokogiri --use-system-libraries`をしましたが失敗しました。

```
bundle config build.nokogiri --use-system-libraries
bundle install --path vendor/bundle

略

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

    /home/vagrant/.rbenv/versions/2.2.4/bin/ruby -r ./siteconf20160108-5747-1ngq14j.rb extconf.rb --use-system-libraries
checking if the C compiler accepts ... yes
Building nokogiri using system libraries.
libxml2 version 2.6.21 or later is required!
*** 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.
```
うーんこれそもそもlibxmlが入っていないパターンですかね(^o^;

```
sudo yum install libxml2 libxslt libxml2-devel libxslt-devel

略

=====================================================================================================================================
 Package                              アーキテクチャー         バージョン                            リポジトリー               容量
=====================================================================================================================================
インストール中:
 libxml2-devel                        x86_64                   2.9.1-6.el7_2.2                       updates                   1.0 M
 libxslt                              x86_64                   1.1.28-5.el7                          base                      242 k
 libxslt-devel                        x86_64                   1.1.28-5.el7                          base                      309 k
更新します:
 libxml2                              x86_64                   2.9.1-6.el7_2.2                       updates                   666 k
依存性関連でのインストールをします:
 libgcrypt-devel                      x86_64                   1.5.3-12.el7_1.1                      base                      129 k
 libgpg-error-devel                   x86_64                   1.12-3.el7                            base                       16 k
 xz-devel                             x86_64                   5.1.2-12alpha.el7                     base                       44 k
依存性関連での更新をします:
 libgcrypt                            x86_64                   1.5.3-12.el7_1.1                      base                      263 k
 xz                                   x86_64                   5.1.2-12alpha.el7                     base                      200 k
 xz-libs                              x86_64                   5.1.2-12alpha.el7                     base                      102 k

トランザクションの要約
=====================================================================================================================================
インストール  3 パッケージ (+3 個の依存関係のパッケージ)
更新          1 パッケージ (+3 個の依存関係のパッケージ)

総ダウンロード容量: 3.0 M
Is this ok [y/d/N]: y
```

# rails s成功

```
bundle install
bundle exec rails s -b 0.0.0.0 -p 8888
=> Booting WEBrick
=> Rails 4.2.0 application starting in development on http://0.0.0.0:8888
=> Run `rails server -h` for more startup options
=> Ctrl-C to shutdown server
[2016-01-08 01:03:24] INFO  WEBrick 1.3.1
[2016-01-08 01:03:24] INFO  ruby 2.2.4 (2015-12-16) [x86_64-linux]
[2016-01-08 01:03:24] INFO  WEBrick::HTTPServer#start: pid=7468 port=8888
```
とりあえず`rails s`まではできました。

# おまけ
Mariadbで動かすには上記以外にコマンドが必要でした。
参考ページのおかげでなんとかなりました。

```
sudo systemctl restart mariadb
sudo systemctl enable mariadb.service

bundle exec rake db:create
bundle exec rake db:migrate
```

# 反省
結局mysqlなのかmariadbなのかよくわからなくなってしまいました。

# 参考

http://blog.ecoteki.com/webservice/post-2567/
2
2
2

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
2
2

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?