“安装json(1.8.0)时出错,而且在Rails中Bundler无法继续”

时间:2020-12-24 05:27:35

I have been given a website that was built using Ruby on Rails. I think the website was built about 3 years ago. 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.

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

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时,我收到此错误:

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文件中添加gem'json','1.8.0',但仍然没有运气

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

2 个解决方案

#1


1  

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

快速编辑:看起来我的下面的答案可能是错的:你需要至少v2.0的json支持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. Also, you have the gem rdoc, which has these requirements:

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

rdoc (3.12)
  json (~> 1.4)

That locks your json gem version to 1.4. You'll either need to live with an older version of json, or update rails and rdoc to handle it.

这将你的json gem版本锁定为1.4。你要么需要使用旧版本的json,要么更新rails和rdoc来处理它。

#2


0  

Try using an earlier version of Ruby (via RBENV or RVM). I switched to Ruby 2.1.10 and the error went away.

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

#1


1  

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

快速编辑:看起来我的下面的答案可能是错的:你需要至少v2.0的json支持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. Also, you have the gem rdoc, which has these requirements:

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

rdoc (3.12)
  json (~> 1.4)

That locks your json gem version to 1.4. You'll either need to live with an older version of json, or update rails and rdoc to handle it.

这将你的json gem版本锁定为1.4。你要么需要使用旧版本的json,要么更新rails和rdoc来处理它。

#2


0  

Try using an earlier version of Ruby (via RBENV or RVM). I switched to Ruby 2.1.10 and the error went away.

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