我正在尝试重建曾经工作过的rails应用程序(最后一次检查是在12月左右)但是在某些系统升级期间停止了工作。当我运行bundle install
时,大多数宝石看起来很好,但之后它会尝试安装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版本,但当然它只列出了依赖于版本{{ 1}}或>=
某些版本,对以后的版本感到满意。
我认为我必须在某处编辑一个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
我在Linux系统上; 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.
为ruby -v
,ruby 2.2.3p173 (2015-08-18 revision 51636) [x86_64-linux]
为bundle -v
。
答案 0 :(得分:1)
您的Gemfile.lock
是捆绑商在运行bundle install
时实际检查的内容,至少在您第一次为给定项目运行捆绑包之后(请参阅this StackOverflow post)。检查该文件,看看是否有任何问题。您也可以尝试删除它并重新运行bundle install
,或者只运行bundle update
以安装所有宝石的最新版本,如果您不关心特定版本。