简体   繁体   English

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

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

I have been given a website that was built using Ruby on Rails. 我得到了一个使用Ruby on Rails构建的网站。 I think the website was built about 3 years ago. 我认为该网站大约建于3年前。 I'm trying to get it up and running on my local machine, but getting a few errors when I try to run the server. 我试图在本地计算机上启动并运行它,但是在尝试运行服务器时遇到一些错误。

Versions: Ruby 2.4.0p0 版本:Ruby 2.4.0p0

Rails 5.1.1 Rails 5.1.1

Homebrew 1.2.3 自制软件1.2.3

Git version 2.11.0 Git版本2.11.0

When I run rails s I get this error: 当我运行rails s以下错误:

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

When I run bundle install I get: 当我运行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.

I have google the error and have tried various things but still no luck. 我有谷歌的错误,并尝试了各种事情,但仍然没有运气。 Some people said to add gem 'json', '1.8.0' to the gem file but still no luck 有人说将gem'json','1.8.0'添加到gem文件中,但还是没有运气

Here is the gemfile 这是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'

Is this because the versions aren't compatible? 这是因为版本不兼容吗?

Gemfile.lock 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)

When I run gem install json -v '1.8.0' I get the following (this was also advised a lot for people who were having the same problem as me but it hasn't worked - even with sudo): 当我运行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

Quick edit: Looks like my below answer could be wrong: you'll need at lease v2.0 of json to support ruby 2.4, as noted here: https://github.com/flori/json/issues/303 快速编辑:看来我的以下答案可能是错误的:您需要在json租借v2.0中支持ruby 2.4,如此处所述: https : //github.com/flori/json/issues/303

It looks like your version of rails is 3.2.6 according to your gemfile. 根据您的gemfile,看起来您的rails版本是3.2.6。 Also, you have the gem rdoc , which has these requirements: 此外,您还有gem rdoc ,它具有以下要求:

rdoc (3.12)
  json (~> 1.4)

That locks your json gem version to 1.4. 这会将您的json gem版本锁定为1.4。 You'll either need to live with an older version of json , or update rails and rdoc to handle it. 您可能需要使用旧版本的json ,或者更新rails和rdoc来处理它。

Try using an earlier version of Ruby (via RBENV or RVM). 尝试使用早期版本的Ruby(通过RBENV或RVM)。 I switched to Ruby 2.1.10 and the error went away. 我切换到Ruby 2.1.10,错误消失了。

暂无
暂无

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

相关问题 安装json(1.8.1)时发生错误,Bundler无法继续 - Rails - An error occurred while installing json (1.8.1), and Bundler cannot continue - Rails 安装json(1.8.6)时出错,Bundler无法继续 - An error occurred while installing json (1.8.6), and Bundler cannot continue 安装 json (1.8.1) 时出错,Bundler 无法继续 - An error occurred while installing json (1.8.1) and Bundler cannot continue 安装 json (1.7.6) 时出错,Bundler 无法继续。 - An error occurred while installing json (1.7.6), and Bundler cannot continue. 安装rails json gem时出错 - bundler无法继续 - Error while installing rails json gem - bundler cannot continue 安装 sqlite3 (1.3.7) 时出错,Bundler 无法继续无法创建 rails 应用程序 - An error occurred while installing sqlite3 (1.3.7), and Bundler cannot continue Cannot create rails app Rails - 错误“安装 sqlite3 (1.3.13) 时出错,Bundler 无法继续” - Rails - error " An error occurred while installing sqlite3 (1.3.13), and Bundler cannot continue" Windows 10上的Rails错误(安装sqlite3(1.4.1)时发生错误,并且Bundler无法继续) - Rails error on windows 10 (An error occurred while installing sqlite3 (1.4.1), and Bundler cannot continue) 安装bcrypt(3.1.11)时发生错误,Bundler无法继续。 - An error occurred while installing bcrypt (3.1.11), and Bundler cannot continue. 安装mysql2(0.3.21)时出错,Bundler无法继续 - An error occurred while installing mysql2 (0.3.21), and Bundler cannot continue
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM