我正在Hartl的Rails教程中構建twitter clone應用程序。我克隆了我的git repo(https://github.com/stewartmccoy/rails_tutorial),並將代碼放到我的個人計算機上,該計算機以前在我的工作計算機上。所以,我的開發環境可能與我在Gemfile中指定的環境略有不同。'運行rspec時找不到pg-0.12.2'
我的環境: 的Mac OS 10.6.8 的Rails 3.2.13 紅寶石1.9.3p392(2013年2月22日修訂39386)x86_64的-darwin10.8.0]
*當地的寶石*
- 的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 )
- 尋址(2.3.2)
- 註釋(2.5.0)
- AREL(3.0.2)
- bcrypt-紅寶石(3.0.1)
- 的BigDecimal(1.1.0)
- bootstrap-sass(2.1.0.0)
- 自舉-will_paginate(0.0.6)
- 助洗劑(3.0.4)
- 捆綁(1.3.4)
- 水豚(2.0.2,1.1.2)
- 子進程(0.3.9, 0.3.6)
- 咖啡導軌(3.2.2)
- 咖啡腳本(2.2.0)
- 咖啡腳本源(1.6.2,1.6.1,1.4.0)
- 黃瓜(1.2.1)
- 黃瓜導軌(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)
- 騙子(1.0.1)
- FFI(1.4.0,1.3.1)
- 小黃瓜(2.11.5 )
- 上調(1.2.1)
- I18N(0.6.1)
- IO-控制檯(0.3)
- 旅程(1.0.4)
- jquery的護欄(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)
- 郵件(2.5.3,2.4.4)
- mime-類型(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)
- 機架(1.4.5,1.4.4,1.4.1)
- 機架緩存(1.2)
- 機架SSL(1.3.3,1.3.2)
- 架測試(0.6.2 )
- 軌(3.2.13,3.2.1)
- railties(3.2.13,3.2.11,3.2.1)
- 耙(10.0.3,0.9.2.2)
- 的RDoc(3.12 0.2,3.12,3.9.5)
- rspec-core(2.13.1)
- rspec的-預期(2.13.0)
- rspec的-嘲笑(2.13.0)
- rspec的護欄(2.13.0)
- 的rubygems打捆(1.1.1)
- rubyzip(0.9.9 )
- RVM(1.11.3.6)
- SASS(3.2.7,3.2.4)
- SASS-軌(3.2.6,3.2.5)
- 硒的webdriver(2.31.0,2.27 .2)
- 鏈輪(2.2.2,2.1。 3)
- sqlite3的(1.3.7)
- 托爾(0.17.0或更新,0.16.0,0.14.6)
- 傾斜(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 '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
無論如何,我想剛上市8後運行測試。18(http://ruby.railstutorial.org/chapters/sign-in-sign-out#sec-reviewing_form_submission):
$ bundle exec rspec spec/models/user_spec.rb
而且我得到這個錯誤:
Could not find pg-0.12.2 in any of the sources
Run `bundle install` to install missing gems.
所以,我跑bundle install
,並與此錯誤:
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.
最後,我想PATH=$PATH:/Library/PostgreSQL/9.2/bin sudo gem install pg
,得到了:
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
意見建議?
非常感謝您的幫助!
啊。我剛剛檢查了我的database.yml文件,並將所有適配器設置爲sqlite3。我需要解決這個問題。奇怪,因爲我認爲我已經將產品設置爲postgres。 – stewartmccoy 2013-04-04 05:15:36
順便說一句,我只是再次檢查你的答案,你實際上遇到了安裝postgres的麻煩,你能讓我知道你的操作系統嗎? – rorra 2013-04-04 05:19:30
我更新的Gemfile: '組:測試:生產做 寶石 'PG', '0.12.2' end' 也database.yml中: '生產: 適配器:在PostgreSQL數據庫 :rails_tutorial 池:5 超時:5000' 但仍獲得: '找不到任何來源 運行'束install'的PG-0.12.2安裝缺少gems.' – stewartmccoy 2013-04-04 05:20:06