我正在关注Michael Hartl Ruby on Rails 教程,并且有一部分是他,他指示您更新 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
仅当'pg', '0.12.2'
使用正确的数据库部署到 heroku 时才需要 gem,即使我将它部署到 heroku 也一切正常,但我只是想知道这是教程中的错误还是我在这里遗漏了更大的东西?
每次运行都要移除这个Gembundle update
也很烦人,bundle update
真的有必要吗?
提前致谢