【问题标题】:`inflate': buffer error (Zlib::BufError) on doing `bundle install``inflate':执行 `bundle install` 时出现缓冲区错误 (Zlib::BufError)
【发布时间】:2014-09-25 00:53:18
【问题描述】:

我正在尝试执行bundle install,但出现以下错误:

Unfortunately, a fatal error has occurred. Please see the Bundler troubleshooting documentation at http://bit.ly/bundler-issues. Thanks!
/home/nish/.rvm/rubies/ruby-1.9.2-p320/lib/ruby/site_ruby/1.9.1/rubygems/util.rb:40:in `inflate': buffer error (Zlib::BufError)
    from /home/nish/.rvm/rubies/ruby-1.9.2-p320/lib/ruby/site_ruby/1.9.1/rubygems/util.rb:40:in `inflate'
    from /home/nish/.rvm/rubies/ruby-1.9.2-p320/lib/ruby/site_ruby/1.9.1/rubygems.rb:536:in `inflate'
    from /home/nish/.rvm/gems/ruby-1.9.2-p320@global/gems/bundler-1.3.5/lib/bundler/fetcher.rb:93:in `fetch_spec'
    from /home/nish/.rvm/gems/ruby-1.9.2-p320@global/gems/bundler-1.3.5/lib/bundler/remote_specification.rb:46:in `_remote_specification'
    from /home/nish/.rvm/gems/ruby-1.9.2-p320@global/gems/bundler-1.3.5/lib/bundler/remote_specification.rb:51:in `method_missing'
    from /home/nish/.rvm/gems/ruby-1.9.2-p320@global/gems/bundler-1.3.5/lib/bundler/index.rb:95:in `block (2 levels) in unmet_dependency_names'
    from /home/nish/.rvm/gems/ruby-1.9.2-p320@global/gems/bundler-1.3.5/lib/bundler/index.rb:94:in `map'
    from /home/nish/.rvm/gems/ruby-1.9.2-p320@global/gems/bundler-1.3.5/lib/bundler/index.rb:94:in `block in unmet_dependency_names'
    from /home/nish/.rvm/gems/ruby-1.9.2-p320@global/gems/bundler-1.3.5/lib/bundler/index.rb:93:in `map'
    from /home/nish/.rvm/gems/ruby-1.9.2-p320@global/gems/bundler-1.3.5/lib/bundler/index.rb:93:in `unmet_dependency_names'
    from /home/nish/.rvm/gems/ruby-1.9.2-p320@global/gems/bundler-1.3.5/lib/bundler/source/rubygems.rb:240:in `remote_specs'
    from /home/nish/.rvm/gems/ruby-1.9.2-p320@global/gems/bundler-1.3.5/lib/bundler/source/rubygems.rb:163:in `fetch_specs'
    from /home/nish/.rvm/gems/ruby-1.9.2-p320@global/gems/bundler-1.3.5/lib/bundler/source/rubygems.rb:67:in `specs'
    from /home/nish/.rvm/gems/ruby-1.9.2-p320@global/gems/bundler-1.3.5/lib/bundler/definition.rb:192:in `block (2 levels) in index'
    from /home/nish/.rvm/gems/ruby-1.9.2-p320@global/gems/bundler-1.3.5/lib/bundler/definition.rb:189:in `each'
    from /home/nish/.rvm/gems/ruby-1.9.2-p320@global/gems/bundler-1.3.5/lib/bundler/definition.rb:189:in `block in index'
    from /home/nish/.rvm/gems/ruby-1.9.2-p320@global/gems/bundler-1.3.5/lib/bundler/index.rb:9:in `build'
    from /home/nish/.rvm/gems/ruby-1.9.2-p320@global/gems/bundler-1.3.5/lib/bundler/definition.rb:185:in `index'
    from /home/nish/.rvm/gems/ruby-1.9.2-p320@global/gems/bundler-1.3.5/lib/bundler/definition.rb:179:in `resolve'
    from /home/nish/.rvm/gems/ruby-1.9.2-p320@global/gems/bundler-1.3.5/lib/bundler/definition.rb:114:in `specs'
    from /home/nish/.rvm/gems/ruby-1.9.2-p320@global/gems/bundler-1.3.5/lib/bundler/definition.rb:109:in `resolve_remotely!'
    from /home/nish/.rvm/gems/ruby-1.9.2-p320@global/gems/bundler-1.3.5/lib/bundler/installer.rb:83:in `run'
    from /home/nish/.rvm/gems/ruby-1.9.2-p320@global/gems/bundler-1.3.5/lib/bundler/installer.rb:14:in `install'
    from /home/nish/.rvm/gems/ruby-1.9.2-p320@global/gems/bundler-1.3.5/lib/bundler/cli.rb:247:in `install'
    from /home/nish/.rvm/gems/ruby-1.9.2-p320@global/gems/bundler-1.3.5/lib/bundler/vendor/thor/task.rb:27:in `run'
    from /home/nish/.rvm/gems/ruby-1.9.2-p320@global/gems/bundler-1.3.5/lib/bundler/vendor/thor/invocation.rb:120:in `invoke_task'
    from /home/nish/.rvm/gems/ruby-1.9.2-p320@global/gems/bundler-1.3.5/lib/bundler/vendor/thor.rb:344:in `dispatch'
    from /home/nish/.rvm/gems/ruby-1.9.2-p320@global/gems/bundler-1.3.5/lib/bundler/vendor/thor/base.rb:434:in `start'
    from /home/nish/.rvm/gems/ruby-1.9.2-p320@global/gems/bundler-1.3.5/bin/bundle:20:in `block in <top (required)>'
    from /home/nish/.rvm/gems/ruby-1.9.2-p320@global/gems/bundler-1.3.5/lib/bundler/friendly_errors.rb:3:in `with_friendly_errors'
    from /home/nish/.rvm/gems/ruby-1.9.2-p320@global/gems/bundler-1.3.5/bin/bundle:20:in `<top (required)>'
    from /home/nish/.rvm/gems/ruby-1.9.2-p320@global/bin/bundle:23:in `load'
    from /home/nish/.rvm/gems/ruby-1.9.2-p320@global/bin/bundle:23:in `<main>'
    from /home/nish/.rvm/gems/ruby-1.9.2-p320@voylla/bin/ruby_noexec_wrapper:14:in `eval'
    from /home/nish/.rvm/gems/ruby-1.9.2-p320@voylla/bin/ruby_noexec_wrapper:14:in `<main>'

我尝试了以下方法:

gem update --sysytem

但我仍然遇到同样的错误。请有人帮忙!谢谢

【问题讨论】:

    标签: ruby-on-rails-3 bundler


    【解决方案1】:

    解决方案

    找出导致问题的原因。在我们使用 geminabox 的情况下,无论出于何种原因,railties-4.1.6.gemspec.rz 已损坏。不知道它是怎么发生的,但它是。所以我们所做的就是删除 railties-4.1.6

    rm shared/gems/proxy/quick/Marshal.4.8/railties-4.1.6.gemspec.rz
    

    之后,系统像往常一样捆绑。如果您遇到同样的问题,您将不得不找到一种方法来观察网络调用并查看它在哪个 GET 事件上停止。

    额外阅读 不修复错误仅在某些情况下抑制它

    之所以可行,是因为新版本碰巧使用了不同版本的 railties。它只是给人的印象是这解决了问题。

    这里有一些关于这个错误的额外信息。但这并不能完全解释为什么会发生这种情况。 cannot install ruby gems - zlib error

    现在他们已经删除或修复了 v2.0.0-p451 中的此代码,但 ruby-2.1.0 尚未合并补丁我还没有回去扔所有代码并检查每个版本但这里是你可以检查的方法.

    What you are looking for 是这个文件。 lib/rubygems/util.rb里面有个方法叫inflate这个方法负责解压gem文件。但是,它存在某种错误,即在无法解压缩的东西上调用它。

    这是一个稳定的版本,你不会找到lib/rubygems/util.rbv2.0.0-p481。所以这很难找到,但是通过查看源代码,您可以找出哪些有这个错误,哪些没有。

    如果您使用的是 rvm,请使用此命令安装正确的版本

    rvm install ruby-2.0.0-p481
    

    要查看所有可用的 ruby​​ 版本,您可以在下面运行此命令。

    $ rvm list known
    
    [ruby-]1.8.6[-p420]
    [ruby-]1.8.7[-head] # security released on head
    [ruby-]1.9.1[-p431]
    [ruby-]1.9.2[-p330]
    [ruby-]1.9.3[-p547]
    [ruby-]2.0.0-p451
    [ruby-]2.0.0[-p481]
    [ruby-]2.1.1
    [ruby-]2.1[.2]
    [ruby-]2.1-head
    ruby-head
    ...
    

    通过更改为该补丁版本,您应该没问题。我也使用ruby-2.0.0-p247 发现了这个错误。

    上面的代码表明你也有这个错误。然而这很奇怪,因为 github repo 说它是在 2013 年 11 月 18 日才引入的。

    https://github.com/ruby/ruby/commit/a7fa4d5d9aab150ad4b0c3f3217fe444df69f527.

    无论如何,我知道这里有很多信息,但是这个错误很棘手。它似乎只影响某些版本的 ruby​​,但由于代码的组织,有时很难判断它是否在您的版本中。最好的方法是检查您是否有 util.rb 文件,如果有则更改版本。

    【讨论】:

    • 更多信息。发现 *.gemspec.rz 文件有可能被损坏。如果是这种情况,最好的解决方案是删除 gemspec.rz 文件并重新安装。
    猜你喜欢
    • 2015-04-01
    • 2015-05-23
    • 2016-06-01
    • 2016-03-29
    • 2021-11-25
    • 1970-01-01
    • 2018-07-11
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多