【问题标题】:How to Install Postgresql Gem on Ubuntu如何在 Ubuntu 上安装 Postgresql Gem
【发布时间】:2015-06-05 08:30:19
【问题描述】:

我在华硕 Chromebook 上通过 crouton 安装了 Ubuntu 12.04 Precise。我有一个需要 postgres 的 rails 应用程序。当我运行“捆绑”时,它无法安装 pg gem。我尝试独立安装它的多个版本,但它失败了。故障报告如下:

构建原生扩展。这可能需要一段时间... 错误:安装 pg 时出错: 错误:无法构建 gem 原生扩展。

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

pg_config... 是 使用来自 /usr/bin/pg_config 的配置值 你需要 安装 postgresql-server-dev-X.Y 用于构建服务器端 扩展或 libpq-dev 用于构建客户端应用程序。你 需要安装 postgresql-server-dev-X.Y 来构建服务器端 扩展或 libpq-dev 用于构建客户端应用程序。 检查 libpq-fe.h... 否 找不到 'libpq-fe.h 标头 * extconf.rb failed * 由于某种原因无法创建 Makefile,可能缺少必要的库和/或头文件。查看 mkmf.log 文件以获取更多详细信息。您可能需要配置 选项。

提供的配置选项: --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 --没有-make-prog --srcdir=。 --curdir --ruby=/home/oscar/.rvm/rubies/ruby-1.9.3-p551/bin/ruby --with-pg --没有-pg --启用-windows-cross --禁用-windows-cross --with-pg-config --without-pg-config --with-pg_config --without-pg_config --with-pg-dir --没有-pg-dir --with-pg-include --without-pg-include=${pg-dir}/include --with-pg-lib --without-pg-lib=${pg-dir}/lib

extconf 失败,退出代码 1

Gem 文件将继续安装在 /home/oscar/.rvm/gems/ruby-1.9.3-p551/gems/pg-0.18.1 供检查。 结果记录到 /home/oscar/.rvm/gems/ruby-1.9.3-p551/extensions/x86_64-linux/1.9.1/pg-0.18.1/gem_make.out

我也尝试使用 brew 安装它。文件已下载,似乎已安装,但是当我运行“brew upgrade postgresql”时,它说 postgresql 没有退出。我完全没有想法,也找不到其他人解决我的问题。

【问题讨论】:

    标签: ruby-on-rails postgresql chromebook


    【解决方案1】:

    据我所知,它说“您需要安装 postgresql-server-dev-XY 来构建服务器端扩展或 libpq-dev 来构建客户端应用程序”这意味着您需要在您的系统上安装软件包以使 gems 工作。

    所以在 Fedora 上我不得不yum install postgresql-devel。由于您使用的是 Ubuntu,我认为您需要这样做

    sudo apt-get install libpq-dev
    

    你可能还需要build-essential,这样你才能运行

    sudo apt-get install libpq-dev build-essential
    

    【讨论】:

    • 这最初是有效的。我能够运行捆绑软件,但后来它卡在了一些东西上,说我需要 ruby​​ 2.0.0 或更高版本。我切换了,但后来我遇到了与以前完全相同的情况
    • 听起来好像您在使用 rvm 时遇到了问题。错误和上面一样吗?如果没有,请在 SO 上提出另一个问题。
    • 我花了大约 10 个小时试图解决这个问题。上面的两个命令对于让它在 ubuntu 16 上运行至关重要。
    猜你喜欢
    • 2011-03-08
    • 1970-01-01
    • 2015-06-01
    • 2014-11-24
    • 1970-01-01
    • 2013-06-21
    • 1970-01-01
    相关资源
    最近更新 更多