An error occurred while installing json (1.8.0), and Bundler cannot continue.

在运行 bundle install时遇到下面问题:

diudiugirl@DIUs:/var/www/ashelf$ bundle install
Fetching gem metadata from https://ruby.taobao.org/...........
Fetching version metadata from https://ruby.taobao.org/..
Resolving dependencies...
Using rake 10.1.0
Using i18n 0.6.9
Using multi_json 1.8.4
Using builder 3.0.4
Using erubis 2.7.0
Using journey 1.0.4
Using rack 1.4.5
Using hike 1.2.3
Using tilt 1.4.1
Using mime-types 1.23
Using polyglot 0.3.3
Using sass 3.2.9
Using thor 0.18.1
Using bcrypt-ruby 3.1.1
Using orm_adapter 0.4.0
Installing json 1.8.0 with native extensions

Gem::Ext::BuildError: ERROR: Failed to build gem native extension.

    current directory: /home/diudiugirl/.rvm/gems/ruby-2.3.0/gems/json-1.8.0/ext/json/ext/generator
/home/diudiugirl/.rvm/rubies/ruby-2.3.0/bin/ruby -r ./siteconf20160201-13134-x1fssx.rb extconf.rb
creating Makefile

current directory: /home/diudiugirl/.rvm/gems/ruby-2.3.0/gems/json-1.8.0/ext/json/ext/generator
make "DESTDIR=" clean

current directory: /home/diudiugirl/.rvm/gems/ruby-2.3.0/gems/json-1.8.0/ext/json/ext/generator
make "DESTDIR="
compiling generator.c
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:238: recipe for target 'generator.o' failed
make: *** [generator.o] Error 1

make failed, exit code 2

Gem files will remain installed in /home/diudiugirl/.rvm/gems/ruby-2.3.0/gems/json-1.8.0 for inspection.
Results logged to /home/diudiugirl/.rvm/gems/ruby-2.3.0/extensions/x86_64-linux/2.3.0/json-1.8.0/gem_make.out
Using fastercsv 1.5.5
Using has_scope 0.5.1
Using arel 3.0.2
Using tzinfo 0.3.37
Using bundler 1.11.2
Using htmlentities 4.3.2
Using mini_portile 0.6.0
Using rubyzip 1.0.0
Using coderay 1.1.0
Using coffee-script-source 1.3.3
Using country_select 1.1.3
Using devise-i18n 0.5.12
Using diff-lcs 1.1.3
Using libv8 3.3.10.4
Using method_source 0.8.2
Using mini_magick 4.1.0
Installing mysql2 0.3.11 with native extensions

Gem::Ext::BuildError: ERROR: Failed to build gem native extension.

    current directory: /home/diudiugirl/.rvm/gems/ruby-2.3.0/gems/mysql2-0.3.11/ext/mysql2
/home/diudiugirl/.rvm/rubies/ruby-2.3.0/bin/ruby -r ./siteconf20160201-13134-1agnvy7.rb extconf.rb
checking for rb_thread_blocking_region()... no
checking for rb_wait_for_single_fd()... yes
checking for mysql.h... yes
checking for errmsg.h... yes
checking for mysqld_error.h... yes
creating Makefile

To see why this extension failed to compile, please check the mkmf.log which can be found here:

  /home/diudiugirl/.rvm/gems/ruby-2.3.0/extensions/x86_64-linux/2.3.0/mysql2-0.3.11/mkmf.log

current directory: /home/diudiugirl/.rvm/gems/ruby-2.3.0/gems/mysql2-0.3.11/ext/mysql2
make "DESTDIR=" clean

current directory: /home/diudiugirl/.rvm/gems/ruby-2.3.0/gems/mysql2-0.3.11/ext/mysql2
make "DESTDIR="
compiling result.c
In file included from ./client.h:11:0,
                 from ./mysql2_ext.h:39,
                 from result.c:1:
/home/diudiugirl/.rvm/rubies/ruby-2.3.0/include/ruby-2.3.0/ruby/backward/rubysig.h:14:2: warning: #warning rubysig.h is obsolete [-Wcpp]
 #warning rubysig.h is obsolete
  ^
In file included from ./mysql2_ext.h:39:0,
                 from result.c:1:
./client.h: In function ‘rb_thread_blocking_region’:
./client.h:23:3: error: ‘TRAP_BEG’ undeclared (first use in this function)
   TRAP_BEG;
   ^
./client.h:23:3: note: each undeclared identifier is reported only once for each function it appears in
./client.h:25:3: error: ‘TRAP_END’ undeclared (first use in this function)
   TRAP_END;
   ^
result.c: In function ‘rb_mysql_result_fetch_row’:
result.c:258:31: warning: variable ‘tokens’ set but not used [-Wunused-but-set-variable]
           int hour, min, sec, tokens;
                               ^
result.c:272:58: warning: variable ‘tokens’ set but not used [-Wunused-but-set-variable]
           unsigned int year, month, day, hour, min, sec, tokens;
                                                          ^
result.c:315:33: warning: variable ‘tokens’ set but not used [-Wunused-but-set-variable]
           int year, month, day, tokens;
                                 ^
Makefile:238: recipe for target 'result.o' failed
make: *** [result.o] Error 1

make failed, exit code 2

Gem files will remain installed in /home/diudiugirl/.rvm/gems/ruby-2.3.0/gems/mysql2-0.3.11 for inspection.
Results logged to /home/diudiugirl/.rvm/gems/ruby-2.3.0/extensions/x86_64-linux/2.3.0/mysql2-0.3.11/gem_make.out
Using slop 3.6.0
Using redcarpet 2.2.2
Using rspec-core 2.11.1
Using rspec-mocks 2.11.3
Using ruby-ip 0.9.1
Using rails-i18n 0.7.2
Using activesupport 3.2.12
Using execjs 1.4.0
Using rack-cache 1.2
Using rack-test 0.6.2
Using rack-ssl 1.3.3
Using warden 1.2.1
Using sprockets 2.2.2
Using treetop 1.4.14
Using bourbon 3.1.8
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.

解决方法:

delete file Gemfile.lock之后再运行bundle install就可以

posted @ 2016-02-01 11:18  Sophiawow  Views(2320)  Comments(0Edit  收藏