2013-08-21 212 views
1

我认为这是一个常见问题,但是我在互联网上找到的解决方案并不适合我。当我运行包本节在我的Gemfile安装软件包安装Postgresql错误

group :production, :staging do 
    gem "pg" 
end 

group :development, :test do 
    gem "sqlite3-ruby", :require => "sqlite3" 
end 

我收到以下错误

creating Makefile 

make 
compiling gvl_wrappers.c 
compiling pg.c 
pg.c: In function ‘Init_pg_ext’: 
pg.c:375: error: ‘PQPING_OK’ undeclared (first use in this function) 
pg.c:375: error: (Each undeclared identifier is reported only once 
pg.c:375: error: for each function it appears in.) 
pg.c:377: error: ‘PQPING_REJECT’ undeclared (first use in this function) 
pg.c:379: error: ‘PQPING_NO_RESPONSE’ undeclared (first use in this function) 
pg.c:381: error: ‘PQPING_NO_ATTEMPT’ undeclared (first use in this function) 
make: *** [pg.o] Error 1 


Gem files will remain installed in /usr/local/rvm/gems/ruby-1.9.3-p194/gems/pg-0.16.0 for inspection. 
Results logged to /usr/local/rvm/gems/ruby-1.9.3-p194/gems/pg-0.16.0/ext/gem_make.out 

下一步,根据我所发现的,是运行locate pg_config,然后将位置命令行语句后的gem install pg。不过,我得到这个错误,而不是:

WARNING: The locate database (/var/db/locate.database) does not exist. 
To create the database, run the following command: 

sudo launchctl load -w /System/Library/LaunchDaemons/com.apple.locate.plist 

Please be aware that the database can take some time to generate; once 
the database has been created, this message will no longer appear. 

我然后运行sudo命令,并获得这最后的错误....

launchctl: Couldn't stat("/System/Library/LaunchDaemons/com.apple.locate.plis"): No such file or directory 
nothing found to load 

这是我在使用该技术的第一次尝试,全新的到Mac也是如此。任何帮助,将不胜感激。谢谢!

编辑

我试图遵循建议located here关于此错误。

+0

这是一个的.plist文件,而不是.plis - 您可以使用mdfind,而不是定位在Mac上。 mdfind使用文件的mac os x spotlight数据库 – Ivan

+0

能够追踪pg_config文件('/ usr/bin/pg_config')的位置,但在将其添加到'gem install'语句后仍然收到相同的错误。 – NealR

回答

1

它看起来像尽管你的gemfile说什么,你试图在本地安装postgres?

真的,这就是你应该做的。在生产中使用本地使用的数据库时,实际上并非最佳选择。我强烈建议在任何地方使用Postgres,并删除sqlite。

在Mac上,这个必杀技的最简单的途径就是安装Postgress.app

+0

好吧,我从链接安装了Postgress.app。然后再次运行上面的所有命令(bundle install,找到pg ..等)并收到相同的错误消息。 – NealR

+0

嗯奇怪。如果你再次运行它,我会猜测在安装pg gem时它会以“/usr/local/rvm/gems/ruby-1.9.3-p194/gems/pg-0.16.0” /ext/foobar.out”。如果是这样,请在这里粘贴foorbar.out的输出。 –

+0

顺便说一句,您指出的要点建议尝试0.15.1。我从来没有任何问题与Ruby 2和PG宝石 - 我看到我使用0.15.1。你可以尝试改变你的Gemfile,使其具有'gem'pg','〜> 0.15.1''行 - 保存并执行捆绑安装,并查看会发生什么? –