无法让 Postgresql 数据库与 Ruby on Rails 3 一起使用
环境
- Windows 7 64位
- Ruby 1.8.7
- Rails 3.0.0
- pg AdminIII
- PostgreSQL 9.0.3
- Cygwin
Gemfile
http://i54.tinypic.com/27yzxv4.png
数据库配置
http://i53.tinypic.com/288b7ma.png
我采取的步骤
- 我尝试添加“gem 'postgres-pr', :require => 'pg'" 到 gemfile
- 尝试安装 postgres gem 的多个变体,
- postgres-pr
- pg
- ruby-pg
当尝试运行 rake db:migrate 时,我不断收到此错误
rake aborted!
no such file to load -- pg
/usr/lib/ruby/gems/1.8/gems/bundler-1.0.10/lib/bundler/runtime.rb:68:in `require'
/usr/lib/ruby/gems/1.8/gems/bundler-1.0.10/lib/bundler/runtime.rb:68:in `require'
/usr/lib/ruby/gems/1.8/gems/bundler-1.0.10/lib/bundler/runtime.rb:66:in `each'
/usr/lib/ruby/gems/1.8/gems/bundler-1.0.10/lib/bundler/runtime.rb:66:in `require'
/usr/lib/ruby/gems/1.8/gems/bundler-1.0.10/lib/bundler/runtime.rb:55:in `each'
/usr/lib/ruby/gems/1.8/gems/bundler-1.0.10/lib/bundler/runtime.rb:55:in `require'
/usr/lib/ruby/gems/1.8/gems/bundler-1.0.10/lib/bundler.rb:120:in `require'
/home/Other/rails_projects/test_project/config/application.rb:7
/usr/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:29:in `gem_original_require'
/usr/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:29:in `require'
/home/Other/rails_projects/test_project/Rakefile:4
/usr/lib/ruby/gems/1.8/gems/rake-0.8.7/lib/rake.rb:2383:in `load'
/usr/lib/ruby/gems/1.8/gems/rake-0.8.7/lib/rake.rb:2383:in `raw_load_rakefile'
/usr/lib/ruby/gems/1.8/gems/rake-0.8.7/lib/rake.rb:2017:in `load_rakefile'
/usr/lib/ruby/gems/1.8/gems/rake-0.8.7/lib/rake.rb:2068:in `standard_exception_handling'
/usr/lib/ruby/gems/1.8/gems/rake-0.8.7/lib/rake.rb:2016:in `load_rakefile'
/usr/lib/ruby/gems/1.8/gems/rake-0.8.7/lib/rake.rb:2000:in `run'
/usr/lib/ruby/gems/1.8/gems/rake-0.8.7/lib/rake.rb:2068:in `standard_exception_handling'
/usr/lib/ruby/gems/1.8/gems/rake-0.8.7/lib/rake.rb:1998:in `run'
/usr/lib/ruby/gems/1.8/gems/rake-0.8.7/bin/rake:31
/usr/bin/rake:19:in `load'
/usr/bin/rake:19
已经这样做了几天,确实需要一些帮助。提前致谢!
Environment
- Windows 7 64 bit
- Ruby 1.8.7
- Rails 3.0.0
- pg AdminIII
- PostgreSQL 9.0.3
- Cygwin
Gemfile
http://i54.tinypic.com/27yzxv4.png
Database Config
http://i53.tinypic.com/288b7ma.png
Steps I have taken
- I tried addding "gem 'postgres-pr', :require => 'pg'" to the gemfile
- Have tried installing multiple variations of the postgres gem,
- postgres-pr
- pg
- ruby-pg
I continually get this error when trying to run rake db:migrate
rake aborted!
no such file to load -- pg
/usr/lib/ruby/gems/1.8/gems/bundler-1.0.10/lib/bundler/runtime.rb:68:in `require'
/usr/lib/ruby/gems/1.8/gems/bundler-1.0.10/lib/bundler/runtime.rb:68:in `require'
/usr/lib/ruby/gems/1.8/gems/bundler-1.0.10/lib/bundler/runtime.rb:66:in `each'
/usr/lib/ruby/gems/1.8/gems/bundler-1.0.10/lib/bundler/runtime.rb:66:in `require'
/usr/lib/ruby/gems/1.8/gems/bundler-1.0.10/lib/bundler/runtime.rb:55:in `each'
/usr/lib/ruby/gems/1.8/gems/bundler-1.0.10/lib/bundler/runtime.rb:55:in `require'
/usr/lib/ruby/gems/1.8/gems/bundler-1.0.10/lib/bundler.rb:120:in `require'
/home/Other/rails_projects/test_project/config/application.rb:7
/usr/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:29:in `gem_original_require'
/usr/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:29:in `require'
/home/Other/rails_projects/test_project/Rakefile:4
/usr/lib/ruby/gems/1.8/gems/rake-0.8.7/lib/rake.rb:2383:in `load'
/usr/lib/ruby/gems/1.8/gems/rake-0.8.7/lib/rake.rb:2383:in `raw_load_rakefile'
/usr/lib/ruby/gems/1.8/gems/rake-0.8.7/lib/rake.rb:2017:in `load_rakefile'
/usr/lib/ruby/gems/1.8/gems/rake-0.8.7/lib/rake.rb:2068:in `standard_exception_handling'
/usr/lib/ruby/gems/1.8/gems/rake-0.8.7/lib/rake.rb:2016:in `load_rakefile'
/usr/lib/ruby/gems/1.8/gems/rake-0.8.7/lib/rake.rb:2000:in `run'
/usr/lib/ruby/gems/1.8/gems/rake-0.8.7/lib/rake.rb:2068:in `standard_exception_handling'
/usr/lib/ruby/gems/1.8/gems/rake-0.8.7/lib/rake.rb:1998:in `run'
/usr/lib/ruby/gems/1.8/gems/rake-0.8.7/bin/rake:31
/usr/bin/rake:19:in `load'
/usr/bin/rake:19
Been at this for a couple days, really need some help. Thanks in advance!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
您需要为 gem 指定正确的平台。在我的 Gemfile 中,我有:(
该组之所以存在,是因为我部署到 Unix 机器上,其中平台明显不同)。我似乎记得我还需要 DevKit 才能正常工作。
You need to specify the correct platform for the gem. In my Gemfile, I have:
(The group is there because I deploy to a Unix box, where the platform is obviously different). I seem to remember that I also needed the DevKit for this to work.
你需要安装 pg 并添加到你的 Gemfile 中
You need to install pg and add to your Gemfile
您可能需要将 Rails 版本升级到 3.0.1 - 3.0.9,并运行
gem install pg
。然后为了更好地重新运行bundle install
。You may need to upgrade your version of Rails to 3.0.1 - 3.0.9 and also run
gem install pg
. Then just for good measure re-runbundle install
.