解决捆绑器 - json 1.8.0。 Ruby 不兼容

Resolving bundler - json 1.8.0. incompatibility in Ruby

我试过 bundle install 如下,但没有成功。

我尝试了很多在这里和那里找到的方法:

请注意,我是 Ruby 的新手,因此这可能是一些简单的解决方案。例如,我需要以某种方式解释捆绑包才能使用 1.8.6.,但我不知道该怎么做。

sudo bundle install
Don't run Bundler as root. Bundler can ask for sudo if it is needed, and installing your bundle as root will break this
application for all non-root users on this machine.
Fetching gem metadata from https://rubygems.org/.........
rails (3.2.14) has dependency bundler (~> 1.0), which is unsatisfied by the current bundler version 2.0.1, so the dependency is being ignored
Using rake 10.1.0
Using clive 1.2.0
Using process_runner 0.0.2
Using rake-compiler 0.9.1
Using timers 1.1.0
Using celluloid 0.14.1
Using contextual_exceptions 0.0.2
Using bundler 2.0.1
Using methadone 1.3.0
Using i18n 0.6.5
Using multi_json 1.7.9
Using activesupport 3.2.14
Using builder 3.0.4
Using activemodel 3.2.14
Using erubis 2.7.0
Using journey 1.0.4
Using rack 1.4.5
Using rack-cache 1.2
Using rack-test 0.6.2
Using hike 1.2.3
Using tilt 1.4.1
Using sprockets 2.2.2
Using actionpack 3.2.14
Using mime-types 1.23
Using polyglot 0.3.3
Using treetop 1.4.14
Using mail 2.5.4
Using actionmailer 3.2.14
Using arel 3.0.2
Using tzinfo 0.3.37
Using activerecord 3.2.14
Using activeresource 3.2.14
Using awesome_print 1.1.0
Using coderay 1.0.9
Using better_errors 0.9.0
Using debug_inspector 0.0.2
Using binding_of_caller 0.7.2
Using rack-ssl 1.3.3
Fetching json 1.8.0
Installing json 1.8.0 with native extensions
Gem::Ext::BuildError: ERROR: Failed to build gem native extension.

    current directory: /home/vagrant/.rbenv/versions/2.3.0/lib/ruby/gems/2.3.0/gems/json-1.8.0/ext/json/ext/generator
/home/vagrant/.rbenv/versions/2.3.0/bin/ruby -r ./siteconf20190205-9598-qp91k4.rb extconf.rb
creating Makefile

current directory: /home/vagrant/.rbenv/versions/2.3.0/lib/ruby/gems/2.3.0/gems/json-1.8.0/ext/json/ext/generator
make "DESTDIR=" clean

current directory: /home/vagrant/.rbenv/versions/2.3.0/lib/ruby/gems/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/vagrant/.rbenv/versions/2.3.0/lib/ruby/gems/2.3.0/gems/json-1.8.0 for inspection.
Results logged to
/home/vagrant/.rbenv/versions/2.3.0/lib/ruby/gems/2.3.0/extensions/x86_64-linux/2.3.0-static/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' --source 'https://rubygems.org/'` succeeds before bundling.

In Gemfile:
  blueprint-rails was resolved to 0.2.0, which depends on
    railties was resolved to 3.2.14, which depends on
      rdoc was resolved to 3.12.2, which depends on
        json
vagrant@vagrant:~/

非常感谢任何帮助。

谢谢!

更新 1:

bundle update json
Fetching gem metadata from https://rubygems.org/.........
Fetching gem metadata from https://rubygems.org/.
Resolving dependencies...
Bundler could not find compatible versions for gem "bundler":
  In Gemfile:
    methadone was resolved to 1.3.0, which depends on
      bundler

    rails (~> 3.2) was resolved to 3.2.14, which depends on
      bundler (~> 1.0)

  Current Bundler version:
    bundler (2.0.1)
This Gemfile requires a different version of Bundler.
Perhaps you need to update Bundler by running `gem install bundler`?

Could not find gem 'bundler (~> 1.0)', which is required by gem 'rails (~> 3.2)', in any of the sources.

更新 2:

gem uninstall bundler

Select gem to uninstall:
 1. bundler-1.0.10
 2. bundler-2.0.1
 3. All versions
> 2

You have requested to uninstall the gem:
    bundler-2.0.1

rails-5.2.2 depends on bundler (>= 1.3.0)
rails-dom-testing-2.0.3 depends on bundler (>= 1.3, development)
If you remove this gem, these dependencies will not be met.
Continue with Uninstall? [yN]

更新 3:

sudo bundle update json
Fetching gem metadata from https://rubygems.org/..........
Fetching version metadata from https://rubygems.org/...
Fetching dependency metadata from https://rubygems.org/..
Resolving dependencies...
Using rake 10.1.0
Using clive 1.2.0
Using process_runner 0.0.2
Using timers 1.1.0
Using contextual_exceptions 0.0.2
Using bundler 1.14.6
Using i18n 0.6.5
Using multi_json 1.7.9
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 arel 3.0.2
Using tzinfo 0.3.37
Using awesome_print 1.1.0
Using coderay 1.0.9
Using debug_inspector 0.0.2
Using json 1.8.6 (was 1.8.0)
Using thor 0.18.1
Using sass 3.2.10
Using callsite 0.0.11
Using mini_portile 0.5.1
Using chunky_png 1.2.8
Using client_side_validations 3.2.6
Using moped 1.4.5
Using origin 1.0.11
Using coffee-script-source 1.6.3
Using haml 3.1.8
Using fssm 0.2.10
Using connection_pool 1.1.0
Using daemon_controller 1.1.5
Using daemons 1.1.9
Using diff-lcs 1.2.4
Installing eventmachine 1.0.3 with native extensions
Using god 0.13.2
Using kramdown 1.1.0
Using metaclass 0.0.1
Using redis 3.0.4
Using require_reloader 0.2.0
Using rspec-core 2.14.5
Using rspec-mocks 2.14.3
Using yard 0.8.7
Using rake-compiler 0.9.1
Using celluloid 0.14.1
Using methadone 1.3.0
Using activesupport 3.2.14
Using execjs 1.4.0
Using rack-cache 1.2
Using rack-test 0.6.2
Using rack-ssl 1.3.3
Using rack-contrib 1.1.0
Using sprockets 2.2.2
Using treetop 1.4.14
Using better_errors 0.9.0
Using binding_of_caller 0.7.2
Using rdoc 3.12.2
Using zen-grids 1.4
Using nokogiri 1.6.0
Using oily_png 1.1.0
Using compass 0.12.2
Using passenger 4.0.10
Using rspec-expectations 2.14.1
Gem::Ext::BuildError: ERROR: Failed to build gem native extension.

    current directory: /home/vagrant/.rbenv/versions/2.3.0/lib/ruby/gems/2.3.0/gems/eventmachine-1.0.3/ext
/home/vagrant/.rbenv/versions/2.3.0/bin/ruby -r ./siteconf20190205-23731-qe1gp5.rb extconf.rb
checking for main() in -lssl... yes
checking for main() in -lcrypto... yes
checking for openssl/ssl.h... yes
checking for openssl/err.h... yes
checking for rb_trap_immediate in ruby.h,rubysig.h... no
checking for rb_thread_blocking_region()... no
checking for inotify_init() in sys/inotify.h... yes
checking for writev() in sys/uio.h... yes
checking for rb_wait_for_single_fd()... yes
checking for rb_enable_interrupt()... no
checking for rb_time_new()... yes
checking for sys/event.h... no
checking for epoll_create() in sys/epoll.h... yes
creating Makefile

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

                                                 ^
Makefile:230: recipe for target 'em.o' failed
make: *** [em.o] Error 1

make failed, exit code 2

Gem files will remain installed in /home/vagrant/.rbenv/versions/2.3.0/lib/ruby/gems/2.3.0/gems/eventmachine-1.0.3 for
inspection.
Results logged to
/home/vagrant/.rbenv/versions/2.3.0/lib/ruby/gems/2.3.0/extensions/x86_64-linux/2.3.0-static/eventmachine-1.0.3/gem_make.out

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

解决方案: 下面的 mjr 答案是一个有效的解决方案,尽管降级 Ruby 也解决了这个问题。

尝试运行宁bundle update json强制更新jsongem。如果这不起作用,您可以 运行 gem clean,再次删除您的 Gemfile.lock 和 运行 所有内容。

编辑:您的捆绑程序版本似乎与您的 rails 版本不兼容。您可以尝试通过 运行ning 降级捆绑器:

  1. gem install bundler --version '1.14.6'
  2. gem uninstall bundler --version '2.0.1'

另外,这是一个新项目吗?如果是这样,您应该考虑使用 rails 5。Rails 3 接近落后三个主要版本,rails 6 的发布也不远了。这也有助于避免很多 gem 问题。