繁体   English   中英

Rails中的“安装json(1.8.0)时发生错误,并且Bundler无法继续”

[英]“An error occurred while installing json (1.8.0), and Bundler cannot continue” in Rails

我得到了一个使用Ruby on Rails构建的网站。 我认为该网站大约建于3年前。 我试图在本地计算机上启动并运行它,但是在尝试运行服务器时遇到一些错误。

版本:Ruby 2.4.0p0

Rails 5.1.1

自制软件1.2.3

Git版本2.11.0

当我运行rails s以下错误:

Could not find proper version of railties (3.2.6) in any of the sources
Run `bundle install` to install missing gems.

当我运行bundle install我得到:

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.

我有谷歌的错误,并尝试了各种事情,但仍然没有运气。 有人说将gem'json','1.8.0'添加到gem文件中,但还是没有运气

这是gemfile

source 'https://rubygems.org'

gem 'rails', '3.2.6'

# Bundle edge Rails instead:
# gem 'rails', :git => 'git://github.com/rails/rails.git'

gem 'mysql2', '> 0.3'
gem 'bluecloth'
gem 'simple_form'
gem 'carrierwave'
gem 'rmagick'
gem 'capistrano'
gem 'rvm-capistrano'

# Gems used only for assets and not required
# in production environments by default.
group :assets do
  gem 'sass-rails',   '~> 3.2.3'
  gem 'coffee-rails', '~> 3.2.1'

  # See https://github.com/sstephenson/execjs#readme for more supported runtimes
  gem 'therubyracer', :platforms => :ruby

  gem 'uglifier', '>= 1.0.3'
end

gem 'jquery-rails'

# To use ActiveModel has_secure_password
# gem 'bcrypt-ruby', '~> 3.0.0'

# To use Jbuilder templates for JSON
# gem 'jbuilder'

# Use unicorn as the app server
# gem 'unicorn'

# Deploy with Capistrano
# gem 'capistrano'

# To use debugger
# gem 'debugger'

这是因为版本不兼容吗?

Gemfile.lock

GEM
  remote: https://rubygems.org/
  specs:
    actionmailer (3.2.6)
      actionpack (= 3.2.6)
      mail (~> 2.4.4)
    actionpack (3.2.6)
      activemodel (= 3.2.6)
      activesupport (= 3.2.6)
      builder (~> 3.0.0)
      erubis (~> 2.7.0)
      journey (~> 1.0.1)
      rack (~> 1.4.0)
      rack-cache (~> 1.2)
      rack-test (~> 0.6.1)
      sprockets (~> 2.1.3)
    activemodel (3.2.6)
      activesupport (= 3.2.6)
      builder (~> 3.0.0)
    activerecord (3.2.6)
      activemodel (= 3.2.6)
      activesupport (= 3.2.6)
      arel (~> 3.0.2)
      tzinfo (~> 0.3.29)
    activeresource (3.2.6)
      activemodel (= 3.2.6)
      activesupport (= 3.2.6)
    activesupport (3.2.6)
      i18n (~> 0.6)
      multi_json (~> 1.0)
    arel (3.0.2)
    bluecloth (2.2.0)
    builder (3.0.0)
    capistrano (2.12.0)
      highline
      net-scp (>= 1.0.0)
      net-sftp (>= 2.0.0)
      net-ssh (>= 2.0.14)
      net-ssh-gateway (>= 1.1.0)
    carrierwave (0.6.2)
      activemodel (>= 3.2.0)
      activesupport (>= 3.2.0)
    coffee-rails (3.2.2)
      coffee-script (>= 2.2.0)
      railties (~> 3.2.0)
    coffee-script (2.2.0)
      coffee-script-source
      execjs
    coffee-script-source (1.3.3)
    erubis (2.7.0)
    execjs (1.4.0)
      multi_json (~> 1.0)
    highline (1.6.12)
    hike (1.2.1)
    i18n (0.6.0)
    journey (1.0.4)
    jquery-rails (2.0.2)
      railties (>= 3.2.0, < 5.0)
      thor (~> 0.14)
    json (1.7.3)
    libv8 (3.16.14.13)
    mail (2.4.4)
      i18n (>= 0.4.0)
      mime-types (~> 1.16)
      treetop (~> 1.4.8)
    mime-types (1.19)
    multi_json (1.3.6)
    mysql2 (0.3.11)
    net-scp (1.0.4)
      net-ssh (>= 1.99.1)
    net-sftp (2.0.5)
      net-ssh (>= 2.0.9)
    net-ssh (2.5.2)
    net-ssh-gateway (1.1.0)
      net-ssh (>= 1.99.1)
    polyglot (0.3.3)
    rack (1.4.1)
    rack-cache (1.2)
      rack (>= 0.4)
    rack-ssl (1.3.2)
      rack
    rack-test (0.6.1)
      rack (>= 1.0)
    rails (3.2.6)
      actionmailer (= 3.2.6)
      actionpack (= 3.2.6)
      activerecord (= 3.2.6)
      activeresource (= 3.2.6)
      activesupport (= 3.2.6)
      bundler (~> 1.0)
      railties (= 3.2.6)
    railties (3.2.6)
      actionpack (= 3.2.6)
      activesupport (= 3.2.6)
      rack-ssl (~> 1.3.2)
      rake (>= 0.8.7)
      rdoc (~> 3.4)
      thor (>= 0.14.6, < 2.0)
    rake (0.9.2.2)
    rdoc (3.12)
      json (~> 1.4)
    ref (2.0.0)
    rmagick (2.13.1)
    rvm-capistrano (1.4.1)
      capistrano (>= 2.0.0)
    sass (3.1.20)
    sass-rails (3.2.5)
      railties (~> 3.2.0)
      sass (>= 3.1.10)
      tilt (~> 1.3)
    simple_form (2.0.1)
      actionpack (~> 3.0)
      activemodel (~> 3.0)
    sprockets (2.1.3)
      hike (~> 1.2)
      rack (~> 1.0)
      tilt (~> 1.1, != 1.3.0)
    therubyracer (0.12.2)
      libv8 (~> 3.16.14.0)
      ref
    thor (0.15.4)
    tilt (1.3.3)
    treetop (1.4.10)
      polyglot
      polyglot (>= 0.3.1)
    tzinfo (0.3.33)
    uglifier (1.2.6)
      execjs (>= 0.3.0)
      multi_json (~> 1.3)

PLATFORMS
  ruby

DEPENDENCIES
  bluecloth
  capistrano
  carrierwave
  coffee-rails (~> 3.2.1)
  jquery-rails
  mysql2 (> 0.3)
  rails (= 3.2.6)
  rmagick
  rvm-capistrano
  sass-rails (~> 3.2.3)
  simple_form
  therubyracer
  uglifier (>= 1.0.3)

当我运行gem install json -v '1.8.0'我得到以下信息(对于与我有相同问题但仍然无法使用的人(即使使用sudo,也有很多建议):

ERROR:  Error installing json:
    ERROR: Failed to build gem native extension.

    current directory: /Users/me/.rvm/gems/ruby-2.4.0/gems/json-1.8.0/ext/json/ext/generator
/Users/me/.rvm/rubies/ruby-2.4.0/bin/ruby -r ./siteconf20170622-61950-1tcycqj.rb extconf.rb
creating Makefile

current directory: /Users/me/.rvm/gems/ruby-2.4.0/gems/json-1.8.0/ext/json/ext/generator
make "DESTDIR=" clean

current directory: /Users/me/.rvm/gems/ruby-2.4.0/gems/json-1.8.0/ext/json/ext/generator
make "DESTDIR="
compiling generator.c
In file included from generator.c:1:
./../fbuffer/fbuffer.h:175:47: error: too few arguments provided to function-like macro invocation
    VALUE result = rb_str_new(FBUFFER_PAIR(fb));
                                              ^
/Users/me/.rvm/rubies/ruby-2.4.0/include/ruby-2.4.0/ruby/intern.h:795:9: note: macro 'rb_str_new' defined here
#define rb_str_new(str, len) RB_GNUC_EXTENSION_BLOCK(   \
        ^
In file included from generator.c:1:
./../fbuffer/fbuffer.h:175:11: warning: incompatible pointer to integer conversion initializing 'VALUE' (aka 'unsigned long') with an expression of type 'VALUE (const char *, long)' (aka 'unsigned long (const char *, long)') [-Wint-conversion]
    VALUE result = rb_str_new(FBUFFER_PAIR(fb));
          ^        ~~~~~~~~~~
generator.c:840:25: error: use of undeclared identifier 'rb_cFixnum'
    } else if (klass == rb_cFixnum) {
                        ^
generator.c:842:25: error: use of undeclared identifier 'rb_cBignum'
    } else if (klass == rb_cBignum) {
                        ^
1 warning and 3 errors generated.
make: *** [generator.o] Error 1

make failed, exit code 2

Gem files will remain installed in /Users/me/.rvm/gems/ruby-2.4.0/gems/json-1.8.0 for inspection.
Results logged to /Users/me/.rvm/gems/ruby-2.4.0/extensions/x86_64-darwin-16/2.4.0/json-1.8.0/gem_make.out

快速编辑:看来我的以下答案可能是错误的:您需要在json租借v2.0中支持ruby 2.4,如此处所述: https : //github.com/flori/json/issues/303

根据您的gemfile,看起来您的rails版本是3.2.6。 此外,您还有gem rdoc ,它具有以下要求:

rdoc (3.12)
  json (~> 1.4)

这会将您的json gem版本锁定为1.4。 您可能需要使用旧版本的json ,或者更新rails和rdoc来处理它。

尝试使用早期版本的Ruby(通过RBENV或RVM)。 我切换到Ruby 2.1.10,错误消失了。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM