【问题标题】:Ruby: Failed to install gems via BundlerRuby:无法通过 Bundler 安装 gem
【发布时间】:2020-04-30 10:12:19
【问题描述】:

我在将我的 ruby​​ 应用程序部署到 Heroku 上时遇到问题。当我推动它时,这是我得到的错误日志。甚至我的 ruby​​ -v 命令也不起作用。甚至不能捆绑更新或捆绑安装。我的 GemFile 读取 ('rails', '3.2.11'), (gem 'sass-rails', '~> 3.2.3') (gem 'coffee-rails', '~> 3.2.1')​​ 和 (gem '注释','2.5.0')(宝石'better_errors')(宝石'binding_of_caller')。对于混乱的格式,我深表歉意,但任何帮助都有效!

remote:        
remote:        current directory:
remote:        /tmp/build_b6e9988ad2a1c287bcb95782c7a546cd/vendor/bundle/ruby/2.6.0/gems/json-1.8.0/ext/json/ext/generator
remote:        /tmp/build_b6e9988ad2a1c287bcb95782c7a546cd/vendor/ruby-2.6.6/bin/ruby -I
remote:        /tmp/build_b6e9988ad2a1c287bcb95782c7a546cd/vendor/ruby-2.6.6/lib/ruby/2.6.0 -r
remote:        ./siteconf20200430-264-zpgrl6.rb extconf.rb
remote:        creating Makefile
remote:        
remote:        current directory:
remote:        /tmp/build_b6e9988ad2a1c287bcb95782c7a546cd/vendor/bundle/ruby/2.6.0/gems/json-1.8.0/ext/json/ext/generator
remote:        make "DESTDIR=" clean
remote:        
remote:        current directory:
remote:        /tmp/build_b6e9988ad2a1c287bcb95782c7a546cd/vendor/bundle/ruby/2.6.0/gems/json-1.8.0/ext/json/ext/generator
remote:        make "DESTDIR="
remote:        compiling generator.c
remote:        In file included from generator.c:1:0:
remote:        ../fbuffer/fbuffer.h: In function ‘fbuffer_to_s’:
remote:        ../fbuffer/fbuffer.h:175:47: error: macro "rb_str_new" requires 2 arguments, but
remote:        only 1 given
remote:             VALUE result = rb_str_new(FBUFFER_PAIR(fb));
remote:                                                       ^
remote:        ../fbuffer/fbuffer.h:175:20: warning: initialization makes integer from pointer
remote:        without a cast [-Wint-conversion]
remote:             VALUE result = rb_str_new(FBUFFER_PAIR(fb));
remote:                            ^~~~~~~~~~
remote:        generator.c: In function ‘generate_json’:
remote:        generator.c:840:25: error: ‘rb_cFixnum’ undeclared (first use in this function);
remote:        did you mean ‘mFixnum’?
remote:             } else if (klass == rb_cFixnum) {
remote:                                 ^~~~~~~~~~
remote:                                 mFixnum
remote:        generator.c:840:25: note: each undeclared identifier is reported only once for
remote:        each function it appears in
remote:        generator.c:842:25: error: ‘rb_cBignum’ undeclared (first use in this function);
remote:        did you mean ‘rb_cFixnum’?
remote:             } else if (klass == rb_cBignum) {
remote:                                 ^~~~~~~~~~
remote:                                 rb_cFixnum
remote:        generator.c: At top level:
remote:        cc1: warning: unrecognized command line option ‘-Wno-self-assign’
remote:        cc1: warning: unrecognized command line option ‘-Wno-parentheses-equality’
remote:        cc1: warning: unrecognized command line option ‘-Wno-constant-logical-operand’
remote:        cc1: warning: unrecognized command line option ‘-Wno-cast-function-type’
remote:        Makefile:244: recipe for target 'generator.o' failed
remote:        make: *** [generator.o] Error 1
remote:        
remote:        make failed, exit code 2
remote:        
remote:        Gem files will remain installed in
remote:        /tmp/build_b6e9988ad2a1c287bcb95782c7a546cd/vendor/bundle/ruby/2.6.0/gems/json-1.8.0
remote:        for inspection.
remote:        Results logged to
remote:        /tmp/build_b6e9988ad2a1c287bcb95782c7a546cd/vendor/bundle/ruby/2.6.0/extensions/x86_64-linux/2.6.0/json-1.8.0/gem_make.out
remote:        
remote:        An error occurred while installing json (1.8.0), and Bundler cannot continue.
remote:        Make sure that `gem install json -v '1.8.0' --source 'https://rubygems.org/'`
remote:        succeeds before bundling.
remote:        
remote:        In Gemfile:
remote:          coffee-rails was resolved to 3.2.2, which depends on
remote:            railties was resolved to 3.2.11, which depends on
remote:              rdoc was resolved to 3.12.2, which depends on
remote:                json
remote: 
remote:  !
remote:  !     Failed to install gems via Bundler.
remote:  !
remote:  !     Push rejected, failed to compile Ruby app.
remote: 
remote:  !     Push failed
remote: Verifying deploy...
remote: 

感谢任何帮助,似乎 JSON 给我带来了最大的麻烦。

【问题讨论】:

    标签: ruby-on-rails json ruby heroku rubygems


    【解决方案1】:

    尝试运行 bundle update json 或者如果它没有帮助,请尝试检查您的捆绑器版本是否与您的 rails 版本兼容

    【讨论】:

    • 我已经尝试了 bundle update json 但它返回一个错误说“找不到 gem 'bundler (~> 1.0)', 这是 gem 'rails (=3.2.11) 所必需的',在任何来源中。”
    【解决方案2】:

    Rails 3.2(及其依赖项,例如您的 json gem 版本)与 Ruby 2.6 不兼容。要解决此问题,您最好升级到更新版本的 Rails(例如 Rails 6.0)。如果你有一个新的 Rails 应用程序,你应该直接从一个新的 Rails 版本开始。如果您有一个现有的应用程序,您可能需要执行代码升级(这可能是密集的),以使您的应用程序与较新的 rails 版本兼容。

    如果你必须使用这么旧的(并且长期不受支持的)Rails 版本,你需要使用旧版本的 Ruby。在 Rails 3.2.11 中,最新支持的 Ruby 版本是 Ruby 1.9.2,它(除了非常过时)仅在 Heroku 的 Cedar-14 堆栈上受支持(该堆栈将在 2020 年 11 月 2 日被删除,届时您肯定必须这样做升级您的应用)

    因此,如果你必须坚持使用 Rails 3.2,你至少应该升级到 3.2.22.5,在那里你可以使用 Ruby 2.2(这两个都已经不支持了)。在 Heroku 上,您需要使用 Heroku-16 堆栈,它支持 Ruby 到 2.2.10 版本。

    不过,您绝对应该尝试升级您的堆栈以使用不到 7 年前更新的软件版本...

    【讨论】:

    • 您好,感谢您的反馈!是的,该项目已有 6 年历史,我试图将其更新为该课程的项目,但即使旧版本仍在运行,我也不知道如何让 heroku 部署它。由于我的项目已有 6 年历史,你会说我应该采取什么行动。如果这是在heroku上部署它所需要的,我有时间执行代码升级,我只是想解决这个格式问题。
    • 如何降级到 1.9.2?
    • 您需要在 Heroku 和 select the right ruby version 上使用 Cedar-14 堆栈。查看 Heroku 文档以获取详细信息。不过,您最好升级您的应用程序。 Rails 更新(至少从 3.2.11 到 r.2.22.5 带来了对新版本的支持)与必须支持令人难以置信的旧 Ruby 和 OS 堆栈相比可能相当小。
    猜你喜欢
    • 1970-01-01
    • 2015-09-23
    • 2019-01-07
    • 2021-08-27
    • 2015-09-15
    • 1970-01-01
    • 1970-01-01
    • 2021-08-26
    • 1970-01-01
    相关资源
    最近更新 更多