3

私はMichael Hartl Ruby on Rails Tutorialに従っています.Gemfileを更新して含めるように指示する部分があります:

group :production do
  gem 'pg', '0.12.2'
end

次に、ターミナルで以下のコマンドを入力します。

bundle update
bundle install --without production

bundle update コマンドを実行すると、以下のエラーがスローされます。

sample_app:$ bundle update
Fetching gem metadata from https://rubygems.org/.........
Fetching gem metadata from https://rubygems.org/..
Resolving dependencies...
Using rake (10.0.3) 
Using i18n (0.6.4) 
etc
[omitted lines for brevity]
etc
Using railties (3.2.12) 
Using coffee-rails (3.2.2) 
Installing diff-lcs (1.1.3) 
Using jquery-rails (2.0.2) 
Installing pg (0.12.2) 
Gem::Installer::ExtensionBuildError: ERROR: Failed to build gem native extension.

        /home/ross/.rvm/rubies/ruby-1.9.3-p392/bin/ruby 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.

Provided configuration options:
    --with-opt-dir
    --without-opt-dir
    --with-opt-include
    etc
    [omitted lines for brevity]
    etc       



Gem files will remain installed in /home/ross/.rvm/gems/ruby-1.9.3-p392/gems/pg-0.12.2 for inspection.
Results logged to /home/ross/.rvm/gems/ruby-1.9.3-p392/gems/pg-0.12.2/ext/gem_make.out

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

このエラーは、 Gemfile'pg', '0.12.2'から gem を削除し、コマンドを実行した後に置き換えることで簡単に解決できました。後者のフラグではgemが省略されているため、これはうまくいくようです。bundle update'pg', '0.12.2'without productionbundle install --without production

gem は、'pg', '0.12.2'正しいデータベースを使用して heroku にデプロイする場合にのみ必要です。heroku にデプロイした場合でもすべて正常に動作しますが、これはチュートリアルのエラーなのか、それとももっと大きなものが欠けているのでしょうか?

を実行するたびにこのGembundle updateを削除しなければならないのも面倒ですが、bundle update本当に必要なのでしょうか?

前もって感謝します

4

2 に答える 2

1

postgres のインストールが次のエラーで失敗する: 「'libpq-fe.h ヘッダーが見つかりません」

多くの人がこの問題に直面しているようです。良いニュースは、stackoverflow に答えがあります ;)

pg gem をインストールしようとすると、「libpq-fe.h」ヘッダーが見つかりません

(または、少なくとも正しい方向を見るのに役立つはずです)

于 2013-03-10T22:06:09.013 に答える