简体   繁体   English

如何在Ubuntu上安装Postgresql Gem

[英]How to Install Postgresql Gem on Ubuntu

I have Ubuntu 12.04 Precise installed via crouton on my Asus Chromebook. 我在华硕Chromebook上通过crouton安装了Ubuntu 12.04 Precise。 I have a rails application that requires postgres. 我有一个需要postgres的rails应用程序。 When I run "bundle" it fails to install the pg gem. 当我运行“bundle”时,它无法安装pg gem。 I try installing multiple versions of it independently and it fails. 我尝试独立安装它的多个版本,但它失败了。 The failure report is below: 失败报告如下:

Building native extensions. 构建原生扩展。 This could take a while... ERROR: Error installing pg: ERROR: Failed to build gem native extension. 这可能需要一段时间...错误:安装pg时出错:错误:无法构建gem原生扩展。

 /home/oscar/.rvm/rubies/ruby-1.9.3-p551/bin/ruby -r ./siteconf20150331-16650-11xjo0a.rb extconf.rb checking for 

pg_config... yes Using config values from /usr/bin/pg_config You need to install postgresql-server-dev-XY for building a server-side extension or libpq-dev for building a client-side application. pg_config ... yes使用/ usr / bin / pg_config中的配置值您需要安装postgresql-server-dev-XY来构建服务器端扩展或libpq-dev来构建客户端应用程序。 You need to install postgresql-server-dev-XY for building a server-side extension or libpq-dev for building a client-side application. 您需要安装postgresql-server-dev-XY来构建服务器端扩展,或者安装libpq-dev来构建客户端应用程序。 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. 检查libpq-fe.h ... no找不到'libpq-fe.h header * extconf.rb失败*由于某些原因无法创建Makefile,可能缺少必要的库和/或头文件。 Check the mkmf.log file for more details. 检查mkmf.log文件以获取更多详细信息。 You may need configuration options. 您可能需要配置选项。

Provided configuration options: --with-opt-dir --without-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=. 提供的配置选项: - with-opt-dir --without-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=/home/oscar/.rvm/rubies/ruby-1.9.3-p551/bin/ruby --with-pg --without-pg --enable-windows-cross --disable-windows-cross --with-pg-config --without-pg-config --with-pg_config --without-pg_config --with-pg-dir --without-pg-dir --with-pg-include --without-pg-include=${pg-dir}/include --with-pg-lib --without-pg-lib=${pg-dir}/lib --curdir --ruby = / home / oscar / .rvm / rubies / ruby​​-1.9.3-p551 / bin / ruby​​ --with-pg --without-pg --enable-windows-cross --disable-windows -cross --with-pg-config --without-pg-config --with-pg_config --with-pg_config --with-pg-dir --without-pg-dir --with-pg-include --without -pg-include = $ {pg-dir} / include --with-pg-lib --without-pg-lib = $ {pg-dir} / lib

extconf failed, exit code 1 extconf失败,退出代码1

Gem files will remain installed in /home/oscar/.rvm/gems/ruby-1.9.3-p551/gems/pg-0.18.1 for inspection. Gem文件将保留在/home/oscar/.rvm/gems/ruby-1.9.3-p551/gems/pg-0.18.1中进行检查。 Results logged to /home/oscar/.rvm/gems/ruby-1.9.3-p551/extensions/x86_64-linux/1.9.1/pg-0.18.1/gem_make.out 结果记录到/home/oscar/.rvm/gems/ruby-1.9.3-p551/extensions/x86_64-linux/1.9.1/pg-0.18.1/gem_make.out

I also tried to install it using brew. 我也尝试使用brew安装它。 The files downloaded, and seem to install but when I run "brew upgrade postgresql" it says that postgresql doesn't exits. 下载的文件,似乎安装,但当我运行“brew upgrade postgresql”时,它说postgresql不会退出。 I am all out of ideas, and I haven't been able to find anyone else with my problem. 我完全没有想法,而且我无法找到任何有问题的人。

As far as I can tell, where it says "You need to install postgresql-server-dev-XY for building a server-side extension or libpq-dev for building a client-side application" it means that you need to install packages on your system for the gems to work. 据我所知,它说“您需要安装postgresql-server-dev-XY来构建服务器端扩展或libpq-dev来构建客户端应用程序”,这意味着您需要安装软件包你的系统让宝石工作。

So on fedora I had to yum install postgresql-devel . 所以在fedora我不得不yum install postgresql-devel Since you're on Ubuntu I think you need to do 因为你在Ubuntu上,我认为你需要这样做

sudo apt-get install libpq-dev

You may also need build-essential so you could run 您可能还需要build-essential以便您可以运行

sudo apt-get install libpq-dev build-essential

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM