【问题标题】:Rails: Gem::Ext::BuildError: ERROR: Failed to build gem native extensionRails:Gem::Ext::BuildError:错误:无法构建 gem 原生扩展
【发布时间】:2017-11-17 01:23:21
【问题描述】:

我在尝试克隆存储库并启动并运行时遇到了问题。 当我运行 bundler 时,我遇到以下错误。出于某种原因,它不喜欢gem pg_query。在我看到的错误消息中:error: '__int128' is not supported for this target 但这超出了我的知识范围。我已尝试阅读类似的帖子,但尚未找到可行的解决方案。

Fetching pg_query 0.11.4
Installing pg_query 0.11.4 with native extensions
Gem::Ext::BuildError: ERROR: Failed to build gem native extension.

    /home/vagrant/.rbenv/versions/2.3.0/bin/ruby extconf.rb
compiling src/pg_query.c
In file included from ./src/postgres/include/postgres.h:47:0,
                 from src/pg_query_internal.h:4,
                 from src/pg_query.c:2:
./src/postgres/include/c.h:298:9: error: '__int128' is not supported for this ta
./src/postgres/include/c.h:298:24: warning: type defaults to 'int' in declaratio
./src/postgres/include/c.h:299:18: error: '__int128' is not supported for this t
make: *** [src/pg_query.o] Error 1
cp: cannot create regular file `./../../spec/files/': No such file or directory
creating Makefile

make "DESTDIR=" clean

make "DESTDIR="
compiling pg_query_ruby.c
pg_query_ruby.c: In function 'pg_query_ruby_parse':
pg_query_ruby.c:80:2: warning: ISO C90 forbids mixed declarations and code [-Wde
pg_query_ruby.c: In function 'pg_query_ruby_normalize':
pg_query_ruby.c:99:2: warning: ISO C90 forbids mixed declarations and code [-Wde
pg_query_ruby.c: In function 'pg_query_ruby_fingerprint':
pg_query_ruby.c:115:2: warning: ISO C90 forbids mixed declarations and code [-Wd
linking shared-object pg_query/pg_query.so
/usr/bin/ld: cannot find -lpg_query
collect2: ld returned 1 exit status
make: *** [pg_query.so] Error 1

make failed, exit code 2

Gem files will remain installed in /home/vagrant/.rbenv/versions/2.3.0/lib/ruby/
Results logged to /home/vagrant/.rbenv/versions/2.3.0/lib/ruby/gems/2.3.0/extens

An error occurred while installing pg_query (0.11.4), and Bundler cannot continu
Make sure that `gem install pg_query -v '0.11.4'` succeeds before bundling.

我尝试运行gem install pg_query -v '0.11.4' 并得到相同的结果。

【问题讨论】:

  • 您的系统上是否安装了postgres 数据库?还在Gemfile 中使用pg gem 并在您的应用程序中使用pg 数据库。
  • 你能做两件事 1) 使用 bundler -v 检查 bundler 版本 2) 然后在 Gemfile.lock 的末尾检查必须有一些 bundler 版本在这里共享
  • @Aniket Shivam Tiwari 好的...所以我有 Bundler -v 1.16 而我的 Gemfile.lock 说 Bundled with 1.15
  • @puneet18 是的,以上我都有
  • 您的问题解决了吗?

标签: ruby-on-rails ruby rubygems


【解决方案1】:

您好,问题出在您的捆绑程序版本上。您的 GemFile 指定较低的捆绑器版本,但您的系统具有较高的捆绑器版本。 请将正确的捆绑器版本与您的 Gemfile.lock 匹配并安装旧版本的捆绑器。试试下面的代码

gem install bundler -v '~> 1.15'
bundle _1.15_ install

【讨论】:

  • 感谢您的回复。我试过了,但仍然遇到同样的错误。即使在我运行gem install bundler -v '~> 1.15' 之后,当我检查bundler -v 时,它仍然说我使用的是1.16 版。我已经尝试以几种不同的方式更改我的捆绑程序版本,但无论如何我 tun bundler -v 它仍然显示 -v 1.16。
  • 首先,卸载所有版本的bundler,然后尝试上述解决方案
猜你喜欢
  • 1970-01-01
  • 2014-06-25
  • 1970-01-01
  • 2015-12-22
  • 1970-01-01
  • 2014-06-10
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多