【发布时间】:2015-08-22 22:19:13
【问题描述】:
我正在尝试重建一个曾经工作的 Rails 应用程序(最后一次检查是在 12 月左右),但在某些系统升级期间停止工作。当我运行bundle install 时,大多数gem 看起来都很好,但随后它会尝试安装json 1.8.0 并失败。
我从网上搜索得知 json 1.8.0 与 ruby 2.2.0 不兼容,因此我尝试安装更新的版本——构建和安装都很好。但是当我重新运行bundle install 时,它再次尝试构建 json 1.8.0,但失败了。我目前的问题是,我完全无法找到为什么它甚至 想要 安装 json 1.8.0;它本身并没有列在我的 Gemfile 中,当我为我的 Gemfile 中的每个 gem 手动运行 sudo gem install XXX 时,安装运行得很好。所以我什至无法弄清楚它有什么将 json 1.8.0 作为依赖项!
我可以运行 gem dependency json -R 并获取成功安装的列表,这取决于我拥有的 json 版本,但当然它只列出依赖于版本 >= 或~>一些版本,对后面的版本很满意。
我假设我必须在某个地方编辑一个 gemfile,告诉它不要使用 json 1.8.0 而是使用 '~> 1.8.0' 或类似的东西。有人知道我应该在哪里寻找吗?
以下是我在 Gemfile 中列出的宝石:
gem 'isbn_validation'
gem 'rails', '4.0.0'
gem 'sqlite3'
gem 'sass-rails', '~> 4.0.0'
gem 'uglifier', '>= 1.3.0'
gem 'coffee-rails', '~> 4.0.0'
gem 'jquery-rails', '~> 3.1.3'
gem 'turbolinks'
gem 'jbuilder', '~> 1.2'
gem 'sdoc', require: false
gem 'devise', '~> 3.2.4'
gem 'cancan', '~> 1.6.10'
gem 'activerecord-session_store'
gem 'paperclip', '~> 4.2.0'
gem dependency json -R 的输出:
Gem json-1.8.1
Used by
activesupport-4.2.3 (json (>= 1.7.7, ~> 1.7))
loofah-2.0.3 (json (>= 0, development))
sprockets-2.12.4 (json (>= 0, development))
uglifier-2.7.1 (json (>= 1.8.0))
Gem json-1.8.2
permutation (>= 0, development)
sdoc (~> 0.3.16, development)
Used by
activesupport-4.2.3 (json (>= 1.7.7, ~> 1.7))
loofah-2.0.3 (json (>= 0, development))
sprockets-2.12.4 (json (>= 0, development))
uglifier-2.7.1 (json (>= 1.8.0))
Gem json-1.8.3
permutation (>= 0, development)
sdoc (~> 0.3.16, development)
Used by
activesupport-4.2.3 (json (>= 1.7.7, ~> 1.7))
loofah-2.0.3 (json (>= 0, development))
sprockets-2.12.4 (json (>= 0, development))
uglifier-2.7.1 (json (>= 1.8.0))
这里是bundle install 输出的略微删节的版本:
Fetching version metadata from https://rubygems.org/...
Fetching dependency metadata from https://rubygems.org/..
Resolving dependencies...
Using rake 10.3.2
Using i18n 0.6.4
Using minitest 4.7.5
Using multi_json 1.7.7
Using atomic 1.1.10
[... omitting many ...]
Using isbn_validation 1.1.1
Using jbuilder 1.4.2
Using jquery-rails 3.1.3 (was 3.0.2)
Installing json 1.8.0 with native extensions
Gem::Ext::BuildError: ERROR: Failed to build gem native extension.
/usr/bin/ruby -r ./siteconf20150822-13426-pdmmtu.rb extconf.rb
creating Makefile
make "DESTDIR=" clean
make "DESTDIR="
compiling generator.c
In file included from /usr/include/stdio.h:27:0,
from /usr/include/ruby-2.2.0/ruby/defines.h:26,
from /usr/include/ruby-2.2.0/ruby/ruby.h:29,
from /usr/include/ruby-2.2.0/ruby.h:33,
from ../fbuffer/fbuffer.h:5,
from generator.c:1:
/usr/include/features.h:328:4: warning: #warning _FORTIFY_SOURCE requires compiling with optimization (-O) [-Wcpp]
# warning _FORTIFY_SOURCE requires compiling with optimization (-O)
^
In file included from generator.c:1:0:
../fbuffer/fbuffer.h: In function ‘fbuffer_to_s’:
../fbuffer/fbuffer.h:175:47: error: macro "rb_str_new" requires 2 arguments, but only 1 given
VALUE result = rb_str_new(FBUFFER_PAIR(fb));
^
../fbuffer/fbuffer.h:175:20: warning: initialization makes integer from pointer without a cast [-Wint-conversion]
VALUE result = rb_str_new(FBUFFER_PAIR(fb));
^
Makefile:237: recipe for target 'generator.o' failed
make: *** [generator.o] Error 1
make failed, exit code 2
Gem files will remain installed in /tmp/bundler20150822-13426-vxbo1gjson-1.8.0/gems/json-1.8.0 for inspection.
Results logged to /tmp/bundler20150822-13426-vxbo1gjson-1.8.0/extensions/x86_64-linux/2.2.0/json-1.8.0/gem_make.out
An error occurred while installing json (1.8.0), and Bundler cannot continue.
Make sure that `gem install json -v '1.8.0'` succeeds before bundling.
我在 Linux 系统上; ruby -v 是 ruby 2.2.3p173 (2015-08-18 revision 51636) [x86_64-linux],bundle -v 是 Bundler version 1.10.6。
【问题讨论】:
标签: ruby-on-rails ruby gem bundler