Rails出现问题 - "无法找到gem 'pg'"

3

大家好。 我在使用Rails时遇到了一些问题。 今天我安装了Rails 3并决定创建一个新项目。

rails new blablabla --database=postgresql

我编辑了database.yml文件,并在其中粘贴了我的数据库、登录名和密码,这些信息是针对PostgreSQL的。我的PostgreSQL使用的端口是5433(而不是5432)。 下面是一个database.yml的示例:

development:
adapter: postgresql
database: devdb
encoding: utf8
username: postgres
password: mypassword
host: localhost
port: 5433

我只想启动服务器或添加控制器,但是Rails提示:

Could not find gem 'pg (>= 0)' in any of the gem sources listed in your Gemfile

但是我有“pg”问题,我认为与端口有关,但我不知道如何解决问题。

抱歉我的英语不好,谢谢回答。

1个回答

4

从错误信息来看,您正在使用Bundler管理项目的宝石。您是否尝试运行bundle install来更新Gemfile中的所有来源?以下是一个示例:

> bundle install
Using rake (0.8.7) 
Using abstract (1.0.0) 
Using activesupport (3.0.3) 
[...]
Using zendesk_remote_auth (0.9.0) 
Your bundle is complete! Use `bundle show [gemname]` to see where a bundled gem is installed.

使用本地扩展安装pg(0.10.1)/usr/local/lib/site_ruby/1.8/rubygems/installer.rb:533:in `build_extensions':ERROR:无法构建宝石本机扩展。(Gem :: Installer :: ExtensionBuildError) - Saska
听起来有进展。剩下的错误消息和堆栈跟踪显示什么?我猜你的系统库缺少某些东西,导致不能编译扩展。 - Wes

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接