【问题标题】:Can't install dm-postgres-adapter无法安装 dm-postgres-adapter
【发布时间】:2014-08-05 14:46:50
【问题描述】:

按照 Heroku 网站上的说明,我安装了Postgress.app,安装了pg gem,安装了data_mapper,一切都很顺利。最后,尝试安装 dm-sqlite-adapter 并得到了这个:

sudo gem install dm-postgres-adapter
Fetching: data_objects-0.10.14.gem (100%)
Successfully installed data_objects-0.10.14
Fetching: do_postgres-0.10.14.gem (100%)
Building native extensions.  This could take a while...
ERROR:  Error installing dm-postgres-adapter:
    ERROR: Failed to build gem native extension.

/System/Library/Frameworks/Ruby.framework/Versions/2.0/usr/bin/ruby extconf.rb
checking for main() in -lpq... yes
checking for libpq-fe.h... yes
checking for libpq/libpq-fs.h... yes
checking for postgres.h... yes
checking for mb/pg_wchar.h... no
*** extconf.rb failed ***
Could not create Makefile due to some reason, probably lack of necessary
libraries and/or headers.  Check the mkmf.log file for more details.  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=.
    --curdir
    --ruby=/System/Library/Frameworks/Ruby.framework/Versions/2.0/usr/bin/ruby
    --with-pgsql-server-dir
    --without-pgsql-server-dir
    --with-pgsql-server-include
    --without-pgsql-server-include=${pgsql-server-dir}/include
    --with-pgsql-server-lib
    --without-pgsql-server-lib=${pgsql-server-dir}/
    --with-pgsql-client-dir
    --without-pgsql-client-dir
    --with-pgsql-client-include
    --without-pgsql-client-include=${pgsql-client-dir}/include
    --with-pgsql-client-lib
    --without-pgsql-client-lib=${pgsql-client-dir}/
    --with-pqlib
    --without-pqlib
Could not find PostgreSQL build environment (libraries & headers): Makefile not created


Gem files will remain installed in /Library/Ruby/Gems/2.0.0/gems/do_postgres-0.10.14 for inspection.
Results logged to /Library/Ruby/Gems/2.0.0/gems/do_postgres-0.10.14/ext/do_postgres/gem_make.out

我也试过了

sudo ARCHFLAGS="-arch x86_64" gem install dm-postgres-adapter

但结果相同。

我查看了 gem_make.out 并在其末尾发现以下内容:

Could not find PostgreSQL build environment (libraries & headers): Makefile not created

有什么建议可以尝试吗?

【问题讨论】:

  • 我安装了 Postgres.app。这是在 Mac 上安装 PostgreSQL 的一种方式。挖掘安装的子文件夹,我可以找到报告丢失的文件,所以我尝试使用各种选项,如sudo ARCHFLAGS="-arch x86_64" gem install dm-postgres-adapter -- --with-pgsql-server-include=/Applications/Postgres.app/Contents/Versions/9.3/include/postgresql/server,但到目前为止没有成功。
  • 试图找出在哪里可以找到它。
  • 嗯,我找到了...但它并没有真正的帮助。它表明所有的头文件实际上都找到了,但是有一堆解析错误,像这样:/Applications/Postgres.app/Contents/Versions/9.3/include/postgresql/server/mb/pg_wchar.h:542:28: error: function cannot return function type 'bool' (aka 'int (int *)') extern bool pg_utf8_islegal(const unsigned char *source, int length); ^ 2 warnings and 15 errors generated.

标签: ruby postgresql sinatra


【解决方案1】:

万岁!我做到了。解决方法很简单:安装 Ruby 2.1.1。然后 dm-postgres-adapter 安装完全没有问题。

【讨论】:

    【解决方案2】:

    这是我能够弄清楚的。

    错误消息(例如找不到某些标头或库)具有误导性。所有这些东西都被成功找到了,但是,正如 mkmf.log 所示,有许多解析错误。这意味着工具链中的某个地方出现了问题。我在 Mac 上,所以这可能是 Xcode 工具、Ruby 版本或某些 gem 的问题,或者其中任何一个由于某种原因不能一起工作......谁知道呢。我在 Stackoverflow 的某个地方看到有人遇到类似问题,通过重新安装整个工具链设法解决了这个问题。

    我决定选择不同的路径。我在 Nitrous.io 上创建了一个 Ruby 盒子,到目前为止一切正常——我能够安装 PostgreSQL 和可怕的 dm-postgres-adapter,以及我需要的所有其他 gem。体验上的巨大差异。

    它仍然不能解决在我的本地计算机上运行 Postgres.app 并从 Sinatra 使用它的问题,但我现在可以忍受。也许有一天我会生气到炸掉整个错误的工具链并重新安装它,但还没有,还没有......

    【讨论】:

      猜你喜欢
      • 2013-09-19
      • 1970-01-01
      • 2011-07-29
      • 2011-05-30
      • 1970-01-01
      • 2017-06-14
      • 2011-05-07
      • 2011-02-10
      • 1970-01-01
      相关资源
      最近更新 更多