私は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 production
bundle install --without production
gem は、'pg', '0.12.2'
正しいデータベースを使用して heroku にデプロイする場合にのみ必要です。heroku にデプロイした場合でもすべて正常に動作しますが、これはチュートリアルのエラーなのか、それとももっと大きなものが欠けているのでしょうか?
を実行するたびにこのGembundle update
を削除しなければならないのも面倒ですが、bundle update
本当に必要なのでしょうか?
前もって感謝します