'运行rspec时无法在任何源中找到pg-0.12.2' [英] 'Could not find pg-0.12.2 in any of the sources' when running rspec

查看:121
本文介绍了'运行rspec时无法在任何源中找到pg-0.12.2'的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在Hartl的Rails教程中构建twitter clone应用程序。我克隆了我的git repo( https://github.com/stewartmccoy/rails_tutorial ),并将代码放到我的个人计算机上,以前一直在我的工作电脑上。所以,我的开发环境可能与我的Gemfile中指定的环境略有不同。



我的环境:
Mac OS 10.6.8
Rails 3.2.13
ruby​​ 1.9.3p392(2013-02-22 revision 39386)[x86_64-darwin10.8.0]



* LOCAL GEMS *


  • actionmailer(3.2.13,3.2.11,3.2.1)

  • actionpack(3.2.13,3.2.11,3.2.1)

  • activemodel(3.2.13,3.2.11,3.2.1)

  • activerecord(3.2.13,3.2.11,3.2.1)

  • activeresource(3.2.13,3.2.11,3.2.1)

  • activesupport(3.2.13,3.2.11,3.2.1)

  • addressable(2.3.2)

  • 批注(2.5.0)

  • arel(3.0.2)

  • bcrypt-ruby(3.0.1)
  • bigdecimal(1.1.0)
  • bootstrap-sass(2.1。 0.0)
  • bootstrap-will_paginate(0.0.6)
  • 构建器(3.0.4)

  • (1.3.4)

  • 水豚(2.0.2,1.1.2)

  • childprocess(0.3.9,0.3.6)
  • >
  • coffee-rails(3.2.2)
  • coffee-script(2.2.0)
  • coffee-script-酸ce(1.6.2,1.6.1,1.4.0)
  • cucumber(1.2.1)

  • cucumber-rails(1.2.1)

  • database_cleaner(0.7.0)
  • diff-lcs(1.2.1,1.1.3)
  • erubis(2.7.0)
  • execjs(1.4.0)
  • factory_girl(4.1.0)
  • factory_girl_rails(4.1.0)

  • faker(1.0.1)

  • ffi(1.4.0,1.3.1)
  • 小黄瓜(2.11.5)

  • 加息(1.2.1)

  • i18n(0.6.1)
  • io-console(0.3)
  • journey(1.0.4)
  • jquery-rails(2.2.1, 2.1.4,2.0.2)

  • json(1.7.7,1.7.6,1.7.5,1.5.5)
  • libwebsocket( (2.5.1,2.4.4)

  • mime-types(1.21,1.19)

  • minitest(2.5.1)
  • multi_json(1.7.1,1.5.0)
    nokogiri(1.5.8,1.5 (0.13.1)

  • polyglot(0.3.3)

  • rack(1.4.5,1.4.4,1.4.1)
  • rack-cache(1.2)
  • rack-ssl(1.3。 3,1.3.2)

  • rack-test(0.6.2)
  • rails(3.2.13,3.2.1)
  • railties(3.2.13,3.2.11,3.2.1)
  • rake(10.0.3,0.9.2.2)

  • rdoc(3.12。 (2.13.1)

  • rspec-expectations(2.13.0)

  • rspec-mocks(2.13.0)

  • rspec-rails(2.13.0)
  • ruby​​gems-bundler(1.1 .1)

  • ruby​​zip(0.9.9)
  • rvm(1.11.3.6)
  • sass(
  • sass-rails(3.2.6,3.2.5)

  • selenium-webdriver(2.31.0, 2.27.2)

  • 链接(2.2.2,2.1.3)
  • sqlite3(1.3.7)

  • thor(0.17.0,0.16.0,0.14.6)
  • tilt(1.3.6,1.3.3)
  • 树梢(1.4.12)

  • tzinfo(0.3.37,0.3.35)
  • uglifier(1.3.0)
  • websocket(1.0.7,1.0.6)

  • will_paginate(3.0.3)
  • xpath(1.0.0,0.1。 4)


我的Gemfile:

  source'htt ps://rubygems.org'

gem'rails','3.2.11'
gem'bootstrap-sass','2.1'
gem'bcrypt-ruby' ,'3.0.1'
gem'faker','1.0.1'
gem'will_paginate','3.0.3'
gem'bootstrap-will_paginate','0.0.6'
gem'jquery-rails','2.0.2'

group:development,:test do
gem'sqlite3','1.3.5'
gem 'rspec-rails','2.11.0'
#gem'guard-rspec','1.2.1'
#gem'guard-spork','1.2.0'
# gem'spork','0.9.2'
end

group:development do
gem'annotate','2.5.0'
end

#默认情况下,Gems仅用于资产,并且在生产环境中不需要
#。
group:assets do
gem'sass-rails','3.2.5'
gem'coffee-rails','3.2.2'
gem'uglifier',' 1.2.3'
结束

组:test do
gem'capybara','1.1.2'
gem'factory_girl_rails','4.1.0'
gem'cucumber-rails','1.2.1',:require => false
gem'database_cleaner','0.7.0'
#gem'launchy','2.1.0'
#gem'rb-fsevent','0.9.1',:require =>假
#gem'growl','1.0.3'
结束

组:生产do
gem'pg','0.12.2'
结束

无论如何,我想在代码清单8.18之后运行测试( http://ruby.railstutorial.org/chapters/sign-in-sign-out#sec-reviewing_form_submission ):

$ p $ $ bundle exec rspec spec / models / user_spec.rb



我得到这个错误:

 可能在任何来源中找不到pg-0.12.2 
运行`bundle install`来安装缺失的宝石。

因此,我运行 bundle install ,得到这个错误:

 从https://rubygems.org / ......... $获取gem元数据b $ b从https://rubygems.org/获取gem元数据。
使用rake(10.0.3)
使用i18n(0.6.1)
使用multi_json(1.5.0)
使用activesupport(3.2.11)
使用构建器(3.0.4)
使用activemodel(3.2.11)
使用erubis(2.7.0)
使用行程(1.0.4)
使用rack(1.4.4)
使用rack-cache(1.2)
使用rack-test(0.6.2)
使用hike(1.2.1) )
使用倾斜(1.3.3)
使用链轮(2.2.2)
使用actionpack(3.2.11)
使用MIME类型(1.19)
使用polyglot(0.3.3)
使用treetop(1.4.12)
使用邮件(2.4.4)
使用actionmailer(3.2.11)
使用arel(3.0.2)
使用tzinfo(0.3.35)
使用activerecord(3.2.11)
使用activeresource(3.2.11)
使用addressable(2.3.2)
使用annotate (2.5.0)
使用bcrypt-ruby(3.0.1)
使用bootstrap-sass(2.1.0.0)
使用will_paginate(3.0.3)
使用bootstrap-will_paginate(0.0.6)
使用nokogiri(1.5.6)
使用ffi(1.3.1)
使用childprocess(0.3.6)
使用websocket(1.0.6)
使用libwebsocket(0.1。 7.1)
使用rubyzip(0.9.9)
使用selenium-webdriver(2.27.2)
使用xpath(0.1.4)
使用capybara(1.1.2)
使用coffee-script-source(1.4.0)
使用execjs(1.4.0)
使用coffee-script(2.2.0)
使用rack-ssl(1.3.2)
使用json(1.7.6)
使用rdoc(3.12)
使用thor(0.16.0)
使用railties(3.2.11)
使用咖啡栏(3.2.2)
使用diff-lcs(1.1.3)
使用小黄瓜(2.11.5)
使用黄瓜(1.2.1)
使用cucumber-rails(1.2 .1)
使用database_cleaner(0.7.0)
使用factory_girl(4.1.0)
使用factory_girl_rails(4.1.0)
使用faker(1.0.1)
使用jquery-rails(2.0.2)
安装pg(0.1 2.2)
Gem :: Installer :: ExtensionBuildError:错误:无法构建gem本机扩展。

/Users/stewartmccoy/.rvm/rubies/ruby-1.9.3-p392/bin/ruby extconf.rb
检查pg_config ... no
没有pg_config。无论如何,尝试。如果构建失败,请再次尝试使用
--with-pg-config = / path / to / pg_config
检查libpq-fe.h ... no
无法找到'libpq-fe.h头文件
*** extconf.rb失败***
由于某种原因无法创建Makefile,可能缺少
必需的库和/或头文件。查看mkmf.log文件以获取更多
的详细信息。您可能需要配置选项。

提供的配置选项:
--with-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 = / Users / stewartmccoy / .rvm / rubies / ruby​​-1.9.3 -p392 / bin / ruby​​
--with-pg
- -without-pg
--with-pg-dir
--without-pg-dir
--with-pg-include
--without-pg-include = $ {pg-dir} / include
--with-pg-lib
--without-pg-lib = $ {pg-dir} / lib $ b $ --with-pg-config
--without-pg-config
--with-pg_config
--without-pg_config


Gem文件将保持安装在/ Users / stewartmccoy /.rvm/gems/ruby-1.9.3-p392/gems/pg-0.12.2进行检查。
结果记录到/Users/stewartmccoy/.rvm/gems/ruby-1.9.3-p392/gems/pg-0.12.2/ext/gem_make.out

发生错误安装pg(0.12.2),并且Bundler无法继续。
确保在捆绑之前`gem install pg -v'0.12.2'`成功。

最后,我尝试了 PATH = $ PATH:/Library/PostgreSQL/9.2 / bin sudo gem install pg 得到:

 密码:
构建原生扩展。这可能需要一段时间...
错误:安装pg时出错:
错误:无法构建gem本机扩展。

/Users/stewartmccoy/.rvm/rubies/ruby-1.9.3-p392/bin/ruby extconf.rb
检查pg_config ... no
没有pg_config。无论如何,尝试。如果构建失败,请再次尝试使用
--with-pg-config = / path / to / pg_config
检查libpq-fe.h ... no
无法找到'libpq-fe.h头文件
*** extconf.rb失败***
由于某种原因无法创建Makefile,可能缺少
必需的库和/或头文件。查看mkmf.log文件以获取更多
的详细信息。您可能需要配置选项。

提供的配置选项:
--with-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 = / Users / stewartmccoy / .rvm / rubies / ruby​​-1.9.3 -p392 / bin / ruby​​
--with-pg
- -without-pg
--with-pg-dir
--without-pg-dir
--with-pg-include
--without-pg-include = $ {pg-dir} / include
--with-pg-lib
--without-pg-lib = $ {pg-dir} / lib $ b $ --with-pg-config
--without-pg-config
--with-pg_config
--without-pg_config


Gem文件将保持安装在/ Users / stewartmccoy /.rvm/gems/ruby-1.9.3-p392/gems/pg-0.15.0进行检查。
结果记录到/Users/stewartmccoy/.rvm/gems/ruby-1.9.3-p392/gems/pg-0.15.0/ext/gem_make.out

建议?



非常感谢您的帮助! 应该检查你在config / database.yml上有什么适配器。可能你已经在 test 环境中设置了postgres或pg适配器。

然而,在你的Gemfile中,你已经为生产设置了postgres:

  group:production do 
gem'pg','0.12.2'
end $ b $如果添加测试环境并再次运行 bundle ,它应该可以工作:

p>

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

另请参阅这个答案



尝试使用以下命令安装gem:

  gem install pg  -  --with-pg-config ='PATH_TO_YOUR_PG_CONFIG'

如果您不知道pg_config的位置,请运行以下命令:

 其中pg_config 

顺便说一句,您是否已经在桌面上安装了postgres?所有你需要的是安装gem的postgres开发包。


I'm working on building the twitter clone app in Hartl's Rails Tutorial. I cloned my git repo (https://github.com/stewartmccoy/rails_tutorial) and put code on to my personal computer, which had previously been on my work computer. So, my developer environment might be slightly different than what's specified in my Gemfile.

My environment: Mac OS 10.6.8 Rails 3.2.13 ruby 1.9.3p392 (2013-02-22 revision 39386) [x86_64-darwin10.8.0]

* LOCAL GEMS *

  • actionmailer (3.2.13, 3.2.11, 3.2.1)
  • actionpack (3.2.13, 3.2.11, 3.2.1)
  • activemodel (3.2.13, 3.2.11, 3.2.1)
  • activerecord (3.2.13, 3.2.11, 3.2.1)
  • activeresource (3.2.13, 3.2.11, 3.2.1)
  • activesupport (3.2.13, 3.2.11, 3.2.1)
  • addressable (2.3.2)
  • annotate (2.5.0)
  • arel (3.0.2)
  • bcrypt-ruby (3.0.1)
  • bigdecimal (1.1.0)
  • bootstrap-sass (2.1.0.0)
  • bootstrap-will_paginate (0.0.6)
  • builder (3.0.4)
  • bundler (1.3.4)
  • capybara (2.0.2, 1.1.2)
  • childprocess (0.3.9, 0.3.6)
  • coffee-rails (3.2.2)
  • coffee-script (2.2.0)
  • coffee-script-source (1.6.2, 1.6.1, 1.4.0)
  • cucumber (1.2.1)
  • cucumber-rails (1.2.1)
  • database_cleaner (0.7.0)
  • diff-lcs (1.2.1, 1.1.3)
  • erubis (2.7.0)
  • execjs (1.4.0)
  • factory_girl (4.1.0)
  • factory_girl_rails (4.1.0)
  • faker (1.0.1)
  • ffi (1.4.0, 1.3.1)
  • gherkin (2.11.5)
  • hike (1.2.1)
  • i18n (0.6.1)
  • io-console (0.3)
  • journey (1.0.4)
  • jquery-rails (2.2.1, 2.1.4, 2.0.2)
  • json (1.7.7, 1.7.6, 1.7.5, 1.5.5)
  • libwebsocket (0.1.7.1)
  • mail (2.5.3, 2.4.4)
  • mime-types (1.21, 1.19)
  • minitest (2.5.1)
  • multi_json (1.7.1, 1.5.0)
  • nokogiri (1.5.8, 1.5.7, 1.5.6)
  • pg (0.14.1)
  • polyglot (0.3.3)
  • rack (1.4.5, 1.4.4, 1.4.1)
  • rack-cache (1.2)
  • rack-ssl (1.3.3, 1.3.2)
  • rack-test (0.6.2)
  • rails (3.2.13, 3.2.1)
  • railties (3.2.13, 3.2.11, 3.2.1)
  • rake (10.0.3, 0.9.2.2)
  • rdoc (3.12.2, 3.12, 3.9.5)
  • rspec-core (2.13.1)
  • rspec-expectations (2.13.0)
  • rspec-mocks (2.13.0)
  • rspec-rails (2.13.0)
  • rubygems-bundler (1.1.1)
  • rubyzip (0.9.9)
  • rvm (1.11.3.6)
  • sass (3.2.7, 3.2.4)
  • sass-rails (3.2.6, 3.2.5)
  • selenium-webdriver (2.31.0, 2.27.2)
  • sprockets (2.2.2, 2.1.3)
  • sqlite3 (1.3.7)
  • thor (0.17.0, 0.16.0, 0.14.6)
  • tilt (1.3.6, 1.3.3)
  • treetop (1.4.12)
  • tzinfo (0.3.37, 0.3.35)
  • uglifier (1.3.0)
  • websocket (1.0.7, 1.0.6)
  • will_paginate (3.0.3)
  • xpath (1.0.0, 0.1.4)

My Gemfile:

source 'https://rubygems.org'

gem 'rails', '3.2.11'
gem 'bootstrap-sass', '2.1'
gem 'bcrypt-ruby', '3.0.1'
gem 'faker', '1.0.1'
gem 'will_paginate', '3.0.3'
gem 'bootstrap-will_paginate', '0.0.6'
gem 'jquery-rails', '2.0.2'

group :development, :test do
  gem 'sqlite3', '1.3.5'
  gem 'rspec-rails', '2.11.0'
  # gem 'guard-rspec', '1.2.1'
  # gem 'guard-spork', '1.2.0'  
  # gem 'spork', '0.9.2'
end

group :development do
  gem 'annotate', '2.5.0'
end

# Gems used only for assets and not required
# in production environments by default.
group :assets do
  gem 'sass-rails',   '3.2.5'
  gem 'coffee-rails', '3.2.2'
  gem 'uglifier', '1.2.3'
end

group :test do
  gem 'capybara', '1.1.2'
  gem 'factory_girl_rails', '4.1.0'
  gem 'cucumber-rails', '1.2.1', :require => false
  gem 'database_cleaner', '0.7.0'
  # gem 'launchy', '2.1.0'
  # gem 'rb-fsevent', '0.9.1', :require => false
  # gem 'growl', '1.0.3'
end

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

Anyway, I'm trying to run the test just after Listing 8.18 (http://ruby.railstutorial.org/chapters/sign-in-sign-out#sec-reviewing_form_submission):

$ bundle exec rspec spec/models/user_spec.rb

And I get this error:

Could not find pg-0.12.2 in any of the sources
Run `bundle install` to install missing gems.

So, I run bundle install and and get this error:

Fetching gem metadata from https://rubygems.org/.........
Fetching gem metadata from https://rubygems.org/..
Using rake (10.0.3) 
Using i18n (0.6.1) 
Using multi_json (1.5.0) 
Using activesupport (3.2.11) 
Using builder (3.0.4) 
Using activemodel (3.2.11) 
Using erubis (2.7.0) 
Using journey (1.0.4) 
Using rack (1.4.4) 
Using rack-cache (1.2) 
Using rack-test (0.6.2) 
Using hike (1.2.1) 
Using tilt (1.3.3) 
Using sprockets (2.2.2) 
Using actionpack (3.2.11) 
Using mime-types (1.19) 
Using polyglot (0.3.3) 
Using treetop (1.4.12) 
Using mail (2.4.4) 
Using actionmailer (3.2.11) 
Using arel (3.0.2) 
Using tzinfo (0.3.35) 
Using activerecord (3.2.11) 
Using activeresource (3.2.11) 
Using addressable (2.3.2) 
Using annotate (2.5.0) 
Using bcrypt-ruby (3.0.1) 
Using bootstrap-sass (2.1.0.0) 
Using will_paginate (3.0.3) 
Using bootstrap-will_paginate (0.0.6) 
Using nokogiri (1.5.6) 
Using ffi (1.3.1) 
Using childprocess (0.3.6) 
Using websocket (1.0.6) 
Using libwebsocket (0.1.7.1) 
Using rubyzip (0.9.9) 
Using selenium-webdriver (2.27.2) 
Using xpath (0.1.4) 
Using capybara (1.1.2) 
Using coffee-script-source (1.4.0) 
Using execjs (1.4.0) 
Using coffee-script (2.2.0) 
Using rack-ssl (1.3.2) 
Using json (1.7.6) 
Using rdoc (3.12) 
Using thor (0.16.0) 
Using railties (3.2.11) 
Using coffee-rails (3.2.2) 
Using diff-lcs (1.1.3) 
Using gherkin (2.11.5) 
Using cucumber (1.2.1) 
Using cucumber-rails (1.2.1) 
Using database_cleaner (0.7.0) 
Using factory_girl (4.1.0) 
Using factory_girl_rails (4.1.0) 
Using faker (1.0.1) 
Using jquery-rails (2.0.2) 
Installing pg (0.12.2) 
Gem::Installer::ExtensionBuildError: ERROR: Failed to build gem native extension.

        /Users/stewartmccoy/.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
    --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=/Users/stewartmccoy/.rvm/rubies/ruby-1.9.3-p392/bin/ruby
    --with-pg
    --without-pg
    --with-pg-dir
    --without-pg-dir
    --with-pg-include
    --without-pg-include=${pg-dir}/include
    --with-pg-lib
    --without-pg-lib=${pg-dir}/lib
    --with-pg-config
    --without-pg-config
    --with-pg_config
    --without-pg_config


Gem files will remain installed in /Users/stewartmccoy/.rvm/gems/ruby-1.9.3-p392/gems/pg-0.12.2 for inspection.
Results logged to /Users/stewartmccoy/.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.

Finally, I tried PATH=$PATH:/Library/PostgreSQL/9.2/bin sudo gem install pg and got:

Password:
Building native extensions.  This could take a while...
ERROR:  Error installing pg:
    ERROR: Failed to build gem native extension.

        /Users/stewartmccoy/.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
    --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=/Users/stewartmccoy/.rvm/rubies/ruby-1.9.3-p392/bin/ruby
    --with-pg
    --without-pg
    --with-pg-dir
    --without-pg-dir
    --with-pg-include
    --without-pg-include=${pg-dir}/include
    --with-pg-lib
    --without-pg-lib=${pg-dir}/lib
    --with-pg-config
    --without-pg-config
    --with-pg_config
    --without-pg_config


Gem files will remain installed in /Users/stewartmccoy/.rvm/gems/ruby-1.9.3-p392/gems/pg-0.15.0 for inspection.
Results logged to /Users/stewartmccoy/.rvm/gems/ruby-1.9.3-p392/gems/pg-0.15.0/ext/gem_make.out

Suggestions?

Thanks so much in advance for your help!

解决方案

You should check what adapters you have on config/database.yml. Probably you have setup the postgres or pg adapter with the test environment.

However, on your Gemfile, you have setup postgres just for production:

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

if you add the test environment and run bundle again, it should work:

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

Also see the solution from this answer:

Try to install the gem with this command:

gem install pg -- --with-pg-config= 'PATH_TO_YOUR_PG_CONFIG'

If you don't know where your pg_config is, run this command:

which pg_config

BTW, did you already install postgres on your desktop? All you need is the postgres development package to install the gem.

这篇关于'运行rspec时无法在任何源中找到pg-0.12.2'的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆