Ruby on rails 3 安装pg(0.12.2)时出错,捆绑程序无法继续

Ruby on rails 3 安装pg(0.12.2)时出错,捆绑程序无法继续,ruby-on-rails-3,rubygems,bundler,railstutorial.org,Ruby On Rails 3,Rubygems,Bundler,Railstutorial.org,我遵循&他指示您更新GEM文件以包括以下内容: 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/......... F

我遵循&他指示您更新GEM文件以包括以下内容:

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,我能够轻松地克服这个错误&在运行
bundle update
命令后替换它。这似乎工作得很好,因为在后一个
捆绑包安装-无生产
中的
无生产
标志中也省略了
'pg',0.12.2'
gem

只有使用正确的数据库部署到heroku时,才需要使用
'pg',0.12.2'
gem&即使我将它部署到heroku,一切都正常,但我只是想知道这是教程中的错误还是我遗漏了更大的错误

每次我运行
包更新
时都必须删除这个Gem也很烦人,
包更新
真的有必要吗


提前感谢

postgres安装失败,出现以下错误:“找不到'libpq fe.h头”

看起来很多人都面临这个问题,好消息是:stackoverflow有了答案;)


(或者至少它可以帮助您朝正确的方向看)

我遵循相同的教程,我认为在不修改现有的依赖项的情况下运行
update
是多余的,但在这种情况下,它甚至会导致问题,因为
update
命令没有
——没有
参数

我偶然发现,其中提到bundler工作流的方式如下:

从文件中添加或删除依赖项后
  • $bundle
  • 提交Gemfile和Gemfile.lock
  • 修改现有依赖项版本后
  • $bundle更新
  • 提交Gemfile和Gemfile.lock

  • 我阅读了
    捆绑包更新
    ,并尝试了,其中包括在
    捆绑包安装后运行
    捆绑包更新

    在我的例子中(省略了一些输出):

    $bundle安装--无需生产
    正在解析依赖项。。。
    使用耙(10.0.3)
    ...
    安装rspec芯(2.11.1)
    您的包已完成!
    
    未安装组生产中的Gems。如果您完全遵循Hartl的GEM文件,那么在没有生产的情况下运行
    bundle install--
    最初会因为锁定而失败。但是,
    bundle更新
    将成功,因为它记住了
    ——而不进行生产
    $ bundle install --without production
    Resolving dependencies...
    Using rake (10.0.3)
    ...
    Installing rspec-core (2.11.1)
    Your bundle is complete!
    Gems in the group production were not installed.             <-- check  
    
    
    $ bundle update
    Resolving dependencies...
    Using rake (10.0.3) 
    ...
    Using uglifier (1.2.3) 
    Your bundle is updated!
    Gems in the group production were not installed.             <-- check