An Error Occurred While Installing Pg 113 and Bundler Cannot Continue Ubuntu

f:id:rdwbocungelt5:20181010100712p:plain

どうもてぃです。

作成したwebアプリをherokuへあげるため、staging環境のみPostgreSQLを入れてテストをしようと思った次第です。

DB周りは安定してエラーが出るのでいつでも身構えて処理できますね。

実行環境

  • ubuntu 16.04.5(elementary OS 0.4.1 Loki)
  • Ruby 2.5.0
  • Rails 5.2.1

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

・ ・ ・ gem 'mysql', '>= 0.4.4', '< 0.6.0' gem 'pg', group: :staging ・ ・ ・

staging環境のみPostgreSQL。

本番環境はMySQLを使う予定(そもそもherokuでテスト運用するならPostgreSQLにすればよかった)。

bundle installすると上記のエラー。

エラー内容は以下。

Fetching pg 1.1.3 Installing pg 1.1.3 with native extensions Gem::Ext::BuildError: ERROR: Failed to build gem native extension.      current directory: /home/user/project/vendor/bundle/ruby/2.5.0/gems/pg-1.1.3/ext /home/user/.rbenv/versions/2.5.0/bin/ruby -r ./siteconf20181005-30856-10oqjtj.rb extconf.rb checking for pg_config... yes Using config values from /usr/bin/pg_config You need to install postgresql-server-dev-X.Y for building a server-side extension or libpq-dev for building a client-side application. You need to install postgresql-server-dev-X.Y for building a server-side extension or libpq-dev for building a client-side application. 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.  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/user/.rbenv/versions/2.5.0/bin/$(RUBY_BASE_NAME)     --with-pg     --without-pg     --enable-windows-cross     --disable-windows-cross     --with-pg-config     --without-pg-config     --with-pg_config     --without-pg_config     --with-pg-dir     --without-pg-dir     --with-pg-include     --without-pg-include=${pg-dir}/include     --with-pg-lib     --without-pg-lib=${pg-dir}/lib  To see why this extension failed to compile, please check the mkmf.log which can be found here:    /home/user/project/vendor/bundle/ruby/2.5.0/extensions/x86_64-linux/2.5.0-static/pg-1.1.3/mkmf.log  extconf failed, exit code 1  Gem files will remain installed in /home/user/project/vendor/bundle/ruby/2.5.0/gems/pg-1.1.3 for inspection. Results logged to /home/user/project/vendor/bundle/ruby/2.5.0/extensions/x86_64-linux/2.5.0-static/pg-1.1.3/gem_make.out  An error occurred while installing pg (1.1.3), and Bundler cannot continue. Make sure that `gem install pg -v '1.1.3'` succeeds before bundling.  In Gemfile:   pg

gemをインストールしてみる

An error occurred while installing pg (1.1.3), and Bundler cannot continue. Make sure that `gem install pg -v '1.1.3'` succeeds before bundling.

こんなこと書いてたので安直にgem installしてみる。

$ gem install pg -v '1.1.3'  Fetching: pg-1.1.3.gem (100%) Building native extensions. This could take a while... ERROR:  Error installing pg:     ERROR: Failed to build gem native extension.      current directory: /home/user/.rbenv/versions/2.5.0/lib/ruby/gems/2.5.0/gems/pg-1.1.3/ext /home/user/.rbenv/versions/2.5.0/bin/ruby -r ./siteconf20181005-31001-qz27e2.rb extconf.rb checking for pg_config... yes Using config values from /usr/bin/pg_config You need to install postgresql-server-dev-X.Y for building a server-side extension or libpq-dev for building a client-side application. You need to install postgresql-server-dev-X.Y for building a server-side extension or libpq-dev for building a client-side application. 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.  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/user/.rbenv/versions/2.5.0/bin/$(RUBY_BASE_NAME)     --with-pg     --without-pg     --enable-windows-cross     --disable-windows-cross     --with-pg-config     --without-pg-config     --with-pg_config     --without-pg_config     --with-pg-dir     --without-pg-dir     --with-pg-include     --without-pg-include=${pg-dir}/include     --with-pg-lib     --without-pg-lib=${pg-dir}/lib  To see why this extension failed to compile, please check the mkmf.log which can be found here:    /home/user/.rbenv/versions/2.5.0/lib/ruby/gems/2.5.0/extensions/x86_64-linux/2.5.0-static/pg-1.1.3/mkmf.log  extconf failed, exit code 1  Gem files will remain installed in /home/user/.rbenv/versions/2.5.0/lib/ruby/gems/2.5.0/gems/pg-1.1.3 for inspection. Results logged to /home/user/.rbenv/versions/2.5.0/lib/ruby/gems/2.5.0/extensions/x86_64-linux/2.5.0-static/pg-1.1.3/gem_make.out

おんなじエラーですね。

よく見てみると、ここらへんがヒントっぽい。

Using config values from /usr/bin/pg_config You need to install postgresql-server-dev-X.Y for building a server-side extension or libpq-dev for building a client-side application. You need to install postgresql-server-dev-X.Y for building a server-side extension or libpq-dev for building a client-side application. checking for libpq-fe.h... no Can't find the 'libpq-fe.h header

てかそもそもlibpq-devって入ってるんかいな?

libpq-devを入れる

$ sudo apt install libpq-dev  パッケージリストを読み込んでいます... 完了 依存関係ツリーを作成しています                 状態情報を読み取っています... 完了 以下の追加パッケージがインストールされます:   comerr-dev krb5-multidev libgssrpc4 libkadm5clnt-mit9 libkadm5srv-mit9 libkdb5-8 提案パッケージ:   krb5-doc krb5-user postgresql-doc-9.5 以下のパッケージが新たにインストールされます:   comerr-dev krb5-multidev libgssrpc4 libkadm5clnt-mit9 libkadm5srv-mit9 libkdb5-8 libpq-dev アップグレード: 0 個、新規インストール: 7 個、削除: 0 個、保留: 198 個。 485 kB のアーカイブを取得する必要があります。 この操作後に追加で 2,528 kB のディスク容量が消費されます。 続行しますか? [Y/n] Y 取得:1 http://jp.archive.ubuntu.com/ubuntu xenial-updates/main amd64 libgssrpc4 amd64 1.13.2+dfsg-5ubuntu2 [54.5 kB] 取得:2 http://jp.archive.ubuntu.com/ubuntu xenial-updates/main amd64 libkdb5-8 amd64 1.13.2+dfsg-5ubuntu2 [37.1 kB] 取得:3 http://jp.archive.ubuntu.com/ubuntu xenial-updates/main amd64 libkadm5srv-mit9 amd64 1.13.2+dfsg-5ubuntu2 [51.3 kB] 取得:4 http://jp.archive.ubuntu.com/ubuntu xenial-updates/main amd64 libkadm5clnt-mit9 amd64 1.13.2+dfsg-5ubuntu2 [36.7 kB] 取得:5 http://jp.archive.ubuntu.com/ubuntu xenial/main amd64 comerr-dev amd64 2.1-1.42.13-1ubuntu1 [38.2 kB] 取得:6 http://jp.archive.ubuntu.com/ubuntu xenial-updates/main amd64 krb5-multidev amd64 1.13.2+dfsg-5ubuntu2 [113 kB] 取得:7 http://jp.archive.ubuntu.com/ubuntu xenial-updates/main amd64 libpq-dev amd64 9.5.14-0ubuntu0.16.04 [154 kB] 485 kB を 1秒 で取得しました (313 kB/s) 以前に未選択のパッケージ libgssrpc4:amd64 を選択しています。 (データベースを読み込んでいます ... 現在 329939 個のファイルとディレクトリがインストールされています。) .../libgssrpc4_1.13.2+dfsg-5ubuntu2_amd64.deb を展開する準備をしています ... libgssrpc4:amd64 (1.13.2+dfsg-5ubuntu2) を展開しています... 以前に未選択のパッケージ libkdb5-8:amd64 を選択しています。 .../libkdb5-8_1.13.2+dfsg-5ubuntu2_amd64.deb を展開する準備をしています ... libkdb5-8:amd64 (1.13.2+dfsg-5ubuntu2) を展開しています... 以前に未選択のパッケージ libkadm5srv-mit9:amd64 を選択しています。 .../libkadm5srv-mit9_1.13.2+dfsg-5ubuntu2_amd64.deb を展開する準備をしています ... libkadm5srv-mit9:amd64 (1.13.2+dfsg-5ubuntu2) を展開しています... 以前に未選択のパッケージ libkadm5clnt-mit9:amd64 を選択しています。 .../libkadm5clnt-mit9_1.13.2+dfsg-5ubuntu2_amd64.deb を展開する準備をしています ... libkadm5clnt-mit9:amd64 (1.13.2+dfsg-5ubuntu2) を展開しています... 以前に未選択のパッケージ comerr-dev を選択しています。 .../comerr-dev_2.1-1.42.13-1ubuntu1_amd64.deb を展開する準備をしています ... comerr-dev (2.1-1.42.13-1ubuntu1) を展開しています... 以前に未選択のパッケージ krb5-multidev を選択しています。 .../krb5-multidev_1.13.2+dfsg-5ubuntu2_amd64.deb を展開する準備をしています ... krb5-multidev (1.13.2+dfsg-5ubuntu2) を展開しています... 以前に未選択のパッケージ libpq-dev を選択しています。 .../libpq-dev_9.5.14-0ubuntu0.16.04_amd64.deb を展開する準備をしています ... libpq-dev (9.5.14-0ubuntu0.16.04) を展開しています... libc-bin (2.23-0ubuntu10) のトリガを処理しています ... man-db (2.7.5-1) のトリガを処理しています ... doc-base (0.10.7) のトリガを処理しています ... doc-base ファイルを 1 個追加 を処理中... scrollkeeper をドキュメントとして登録しています... install-info (6.1.0.dfsg.1-5) のトリガを処理しています ... libgssrpc4:amd64 (1.13.2+dfsg-5ubuntu2) を設定しています ... libkdb5-8:amd64 (1.13.2+dfsg-5ubuntu2) を設定しています ... libkadm5srv-mit9:amd64 (1.13.2+dfsg-5ubuntu2) を設定しています ... libkadm5clnt-mit9:amd64 (1.13.2+dfsg-5ubuntu2) を設定しています ... comerr-dev (2.1-1.42.13-1ubuntu1) を設定しています ... krb5-multidev (1.13.2+dfsg-5ubuntu2) を設定しています ... libpq-dev (9.5.14-0ubuntu0.16.04) を設定しています ... libc-bin (2.23-0ubuntu10) のトリガを処理しています ...

うまくいった。

再びgem install

$ gem install pg -v '1.1.3'  Building native extensions. This could take a while... Successfully installed pg-1.1.3 Parsing documentation for pg-1.1.3 Installing ri documentation for pg-1.1.3 Done installing documentation for pg after 0 seconds 1 gem installed

お、はいったぞ。

そして無事bundle installも通りました。

これからherokuへデプロイするぞー。

munozgrenown.blogspot.com

Source: https://smot93516.hatenablog.jp/entry/2018/10/05/152936

0 Response to "An Error Occurred While Installing Pg 113 and Bundler Cannot Continue Ubuntu"

Post a Comment

Iklan Atas Artikel

Iklan Tengah Artikel 1

Iklan Tengah Artikel 2

Iklan Bawah Artikel