当前位置:  开发笔记 > 后端 > 正文

Capistrano损坏Gemfile.lock错误

如何解决《Capistrano损坏Gemfile.lock错误》经验,为你挑选了1个好方法。

我正在尝试使用Capistrano部署我的应用程序,但我收到此错误:

Your Gemfile.lock is corrupt. The following gem is missing from the DEPENDENCIES
section: 'nokogiri'

我看到这个问题,不幸的是,解决方案(切换Bundler版本)对我不起作用: Travis报告了损坏的Gemfile.lock的奇怪消息

我试过:在添加到我之后删除gemfile.lock(和做一个bundle _1.10.6_ install),但我仍然得到同样的错误.nokogirigemfile

这是我的gemfile:

source 'http://rubygems.org' 

gem 'rails', '4.2.5'
gem 'mysql2', '0.4.2'
gem 'sass-rails', '~> 4.0.3'
gem 'uglifier', '>= 1.3.0'
gem 'coffee-rails', '~> 4.0.0'
gem 'jquery-rails', '4.0.5'
gem 'turbolinks', '2.5.3'
gem 'jbuilder', '~> 2.0'
gem 'sdoc', '~> 0.4.0',          group: :doc

gem 'whenever', '0.9.4', :require => false
gem 'simple_form', '3.2.0' 
gem 'devise', '3.5.2' 
gem 'omniauth-facebook', '3.0.0' 
gem "cocoon", '1.2.6' 
gem "paperclip", "~> 4.3" 
gem 'braintree', '2.55.0'
gem 'figaro', '~> 0.7.0'
gem 'activeadmin', github: 'activeadmin' 
gem 'aws-sdk-v1', '1.66.0'
gem 'transloadit-rails', '1.1.2' 
gem 'ratyrate', '1.2.2.alpha' 
gem "mediaelement_rails", '0.8.2' 
gem 'will_paginate', '~> 3.0.6' 
gem 'will_paginate-bootstrap', '1.0.1' 
gem 'ransack', '1.7.0' 
gem 'jquery-turbolinks', '2.1.0' 
gem 'meta-tags', '2.1.0' 
gem 'sitemap_generator', '5.1.0' 
gem 'nokogiri'

我的gemfile.lock:

GIT
  remote: git://github.com/activeadmin/activeadmin.git
  revision: ab1d8d1a4a1af748ae7009d9d725193d780d0059
  specs:
    activeadmin (1.0.0.pre2)
      arbre (~> 1.0, >= 1.0.2)
      bourbon
      coffee-rails
      formtastic (~> 3.1)
      formtastic_i18n
      inherited_resources (~> 1.6)
      jquery-rails
      jquery-ui-rails
      kaminari (~> 0.15)
      rails (>= 3.2, < 5.0)
      ransack (~> 1.3)
      sass-rails

GEM
  remote: http://rubygems.org/
  specs:
    actionmailer (4.2.5)
      actionpack (= 4.2.5)
      actionview (= 4.2.5)
      activejob (= 4.2.5)
      mail (~> 2.5, >= 2.5.4)
      rails-dom-testing (~> 1.0, >= 1.0.5)
    actionpack (4.2.5)
      actionview (= 4.2.5)
      activesupport (= 4.2.5)
      rack (~> 1.6)
      rack-test (~> 0.6.2)
      rails-dom-testing (~> 1.0, >= 1.0.5)
      rails-html-sanitizer (~> 1.0, >= 1.0.2)
    actionview (4.2.5)
      activesupport (= 4.2.5)
      builder (~> 3.1)
      erubis (~> 2.7.0)
      rails-dom-testing (~> 1.0, >= 1.0.5)
      rails-html-sanitizer (~> 1.0, >= 1.0.2)
    activejob (4.2.5)
      activesupport (= 4.2.5)
      globalid (>= 0.3.0)
    activemodel (4.2.5)
      activesupport (= 4.2.5)
      builder (~> 3.1)
    activerecord (4.2.5)
      activemodel (= 4.2.5)
      activesupport (= 4.2.5)
      arel (~> 6.0)
    activesupport (4.2.5)
      i18n (~> 0.7)
      json (~> 1.7, >= 1.7.7)
      minitest (~> 5.1)
      thread_safe (~> 0.3, >= 0.3.4)
      tzinfo (~> 1.1)
    arbre (1.0.3)
      activesupport (>= 3.0.0)
    arel (6.0.3)
    aws-sdk-v1 (1.66.0)
      json (~> 1.4)
      nokogiri (>= 1.4.4)
    bcrypt (3.1.10-x86-mingw32)
    bourbon (3.2.4)
      sass (~> 3.2)
      thor
    braintree (2.55.0)
      builder (>= 2.0.0)
    builder (3.2.2)
    chronic (0.10.2)
    climate_control (0.0.3)
      activesupport (>= 3.0)
    cocaine (0.5.8)
      climate_control (>= 0.0.3, < 1.0)
    cocoon (1.2.6)
    coffee-rails (4.0.1)
      coffee-script (>= 2.2.0)
      railties (>= 4.0.0, < 5.0)
    coffee-script (2.4.1)
      coffee-script-source
      execjs
    coffee-script-source (1.10.0)
    devise (3.5.2)
      bcrypt (~> 3.0)
      orm_adapter (~> 0.1)
      railties (>= 3.2.6, < 5)
      responders
      thread_safe (~> 0.1)
      warden (~> 1.2.3)
    domain_name (0.5.25)
      unf (>= 0.0.5, < 1.0.0)
    erubis (2.7.0)
    execjs (2.6.0)
    faraday (0.9.2)
      multipart-post (>= 1.2, < 3)
    ffi (1.9.10-x86-mingw32)
    figaro (0.7.0)
      bundler (~> 1.0)
      rails (>= 3, < 5)
    formtastic (3.1.3)
      actionpack (>= 3.2.13)
    formtastic_i18n (0.4.1)
    globalid (0.3.6)
      activesupport (>= 4.1.0)
    has_scope (0.6.0)
      actionpack (>= 3.2, < 5)
      activesupport (>= 3.2, < 5)
    hashie (3.4.3)
    hike (1.2.3)
    http-cookie (1.0.2)
      domain_name (~> 0.5)
    i18n (0.7.0)
    inherited_resources (1.6.0)
      actionpack (>= 3.2, < 5)
      has_scope (~> 0.6.0.rc)
      railties (>= 3.2, < 5)
      responders
    jbuilder (2.4.0)
      activesupport (>= 3.0.0, < 5.1)
      multi_json (~> 1.2)
    jquery-rails (4.0.5)
      rails-dom-testing (~> 1.0)
      railties (>= 4.2.0)
      thor (>= 0.14, < 2.0)
    jquery-turbolinks (2.1.0)
      railties (>= 3.1.0)
      turbolinks
    jquery-ui-rails (5.0.5)
      railties (>= 3.2.16)
    json (1.8.3)
    jwt (1.5.2)
    kaminari (0.16.3)
      actionpack (>= 3.0.0)
      activesupport (>= 3.0.0)
    loofah (2.0.3)
      nokogiri (>= 1.5.9)
    mail (2.6.3)
      mime-types (>= 1.16, < 3)
    mediaelement_rails (0.8.2)
      jquery-rails (>= 1.0)
      railties (>= 3.1)
    meta-tags (2.1.0)
      actionpack (>= 3.0.0)
    mime-types (2.99)
    mimemagic (0.3.0)
    mini_portile2 (2.0.0)
    minitest (5.8.3)
    multi_json (1.11.2)
    multi_xml (0.5.5)
    multipart-post (2.0.0)
    mysql2 (0.4.2-x86-mingw32)
    netrc (0.11.0)
    nokogiri (1.6.7.1-x86-mingw32)
      mini_portile2 (~> 2.0.0.rc2)
    oauth2 (1.0.0)
      faraday (>= 0.8, < 0.10)
      jwt (~> 1.0)
      multi_json (~> 1.3)
      multi_xml (~> 0.5)
      rack (~> 1.2)
    omniauth (1.3.1)
      hashie (>= 1.2, < 4)
      rack (>= 1.0, < 3)
    omniauth-facebook (3.0.0)
      omniauth-oauth2 (~> 1.2)
    omniauth-oauth2 (1.4.0)
      oauth2 (~> 1.0)
      omniauth (~> 1.2)
    orm_adapter (0.5.0)
    paperclip (4.3.2)
      activemodel (>= 3.2.0)
      activesupport (>= 3.2.0)
      cocaine (~> 0.5.5)
      mime-types
      mimemagic (= 0.3.0)
    polyamorous (1.3.0)
      activerecord (>= 3.0)
    quiet_assets (1.1.0)
      railties (>= 3.1, < 5.0)
    rack (1.6.4)
    rack-test (0.6.3)
      rack (>= 1.0)
    rails (4.2.5)
      actionmailer (= 4.2.5)
      actionpack (= 4.2.5)
      actionview (= 4.2.5)
      activejob (= 4.2.5)
      activemodel (= 4.2.5)
      activerecord (= 4.2.5)
      activesupport (= 4.2.5)
      bundler (>= 1.3.0, < 2.0)
      railties (= 4.2.5)
      sprockets-rails
    rails-deprecated_sanitizer (1.0.3)
      activesupport (>= 4.2.0.alpha)
    rails-dom-testing (1.0.7)
      activesupport (>= 4.2.0.beta, < 5.0)
      nokogiri (~> 1.6.0)
      rails-deprecated_sanitizer (>= 1.0.1)
    rails-html-sanitizer (1.0.2)
      loofah (~> 2.0)
    railties (4.2.5)
      actionpack (= 4.2.5)
      activesupport (= 4.2.5)
      rake (>= 0.8.7)
      thor (>= 0.18.1, < 2.0)
    rake (10.4.2)
    ransack (1.7.0)
      actionpack (>= 3.0)
      activerecord (>= 3.0)
      activesupport (>= 3.0)
      i18n
      polyamorous (~> 1.2)
    ratyrate (1.2.2.alpha)
    rdoc (4.2.1)
      json (~> 1.4)
    responders (2.1.1)
      railties (>= 4.2.0, < 5.1)
    rest-client (1.8.0-x86-mingw32)
      ffi (~> 1.9)
      http-cookie (>= 1.0.2, < 2.0)
      mime-types (>= 1.16, < 3.0)
      netrc (~> 0.7)
    sass (3.2.19)
    sass-rails (4.0.5)
      railties (>= 4.0.0, < 5.0)
      sass (~> 3.2.2)
      sprockets (~> 2.8, < 3.0)
      sprockets-rails (~> 2.0)
    sdoc (0.4.1)
      json (~> 1.7, >= 1.7.7)
      rdoc (~> 4.0)
    simple_form (3.2.0)
      actionpack (~> 4.0)
      activemodel (~> 4.0)
    sitemap_generator (5.1.0)
      builder
    sprockets (2.12.4)
      hike (~> 1.2)
      multi_json (~> 1.0)
      rack (~> 1.0)
      tilt (~> 1.1, != 1.3.0)
    sprockets-rails (2.3.3)
      actionpack (>= 3.0)
      activesupport (>= 3.0)
      sprockets (>= 2.8, < 4.0)
    thor (0.19.1)
    thread_safe (0.3.5)
    tilt (1.4.1)
    transloadit (1.2.0)
      mime-types (~> 2.99)
      multi_json
      rest-client
    transloadit-rails (1.1.2)
      mime-types (~> 2.99)
      railties (>= 3)
      transloadit (>= 1.1.1)
    turbolinks (2.5.3)
      coffee-rails
    tzinfo (1.2.2)
      thread_safe (~> 0.1)
    tzinfo-data (1.2015.7)
      tzinfo (>= 1.0.0)
    uglifier (2.7.2)
      execjs (>= 0.3.0)
      json (>= 1.8.0)
    unf (0.1.4)
      unf_ext
    unf_ext (0.0.7.1-x86-mingw32)
    warden (1.2.4)
      rack (>= 1.0)
    whenever (0.9.4)
      chronic (>= 0.6.3)
    will_paginate (3.0.7)
    will_paginate-bootstrap (1.0.1)
      will_paginate (>= 3.0.3)

PLATFORMS
  x86-mingw32

DEPENDENCIES
  activeadmin!
  aws-sdk-v1 (= 1.66.0)
  braintree (= 2.55.0)
  cocoon (= 1.2.6)
  coffee-rails (~> 4.0.0)
  devise (= 3.5.2)
  figaro (~> 0.7.0)
  jbuilder (~> 2.0)
  jquery-rails (= 4.0.5)
  jquery-turbolinks (= 2.1.0)
  mediaelement_rails (= 0.8.2)
  meta-tags (= 2.1.0)
  mysql2 (= 0.4.2)
  nokogiri
  omniauth-facebook (= 3.0.0)
  paperclip (~> 4.3)
  quiet_assets
  rails (= 4.2.5)
  ransack (= 1.7.0)
  ratyrate (= 1.2.2.alpha)
  sass-rails (~> 4.0.3)
  sdoc (~> 0.4.0)
  simple_form (= 3.2.0)
  sitemap_generator (= 5.1.0)
  transloadit-rails (= 1.1.2)
  turbolinks (= 2.5.3)
  tzinfo-data
  uglifier (>= 1.3.0)
  whenever (= 0.9.4)
  will_paginate (~> 3.0.6)
  will_paginate-bootstrap (= 1.0.1)

BUNDLED WITH
   1.10.6

Matt Brictso.. 9

看起来您正在使用Windows机器进行开发.我的猜测是你正在尝试部署到Linux.我很遗憾地说,这不会起作用.

您会注意到您的Gemfile.lock引用了Nokogiri的x86-mingw32版本,该版本无法在服务器上使用.

遗憾的是,没有简单的解决方案.Heroku通过在部署期间完全删除Gemfile.lock来解决此问题,这迫使Bundler重新解析所有依赖项.这样可行,但现在您的依赖项不再被锁定且无法预测.Heroku会说:

删除,Gemfile.lock因为它是在Windows上生成的.Bundler将完全解决,以便正确处理原生宝石.这可能会导致您的应用中使用意外的gem版本.在极少数情况下,Bundler可能根本无法解析您的依赖项. https://devcenter.heroku.com/articles/bundler-windows-gemfile

您可以在Capistrano中执行类似的操作,使用一些自定义代码在Bundler任务运行之前删除Gemfile.lock(或者只是完全从源代码控制中删除Gemfile.lock).您还必须更改Bundler参数以删除该--deployment标志,否则当它看到Gemfile.lock丢失时它将失败.

或者您可以将开发环境切换到Mac或Linux,例如使用Linux VM进行开发.



1> Matt Brictso..:

看起来您正在使用Windows机器进行开发.我的猜测是你正在尝试部署到Linux.我很遗憾地说,这不会起作用.

您会注意到您的Gemfile.lock引用了Nokogiri的x86-mingw32版本,该版本无法在服务器上使用.

遗憾的是,没有简单的解决方案.Heroku通过在部署期间完全删除Gemfile.lock来解决此问题,这迫使Bundler重新解析所有依赖项.这样可行,但现在您的依赖项不再被锁定且无法预测.Heroku会说:

删除,Gemfile.lock因为它是在Windows上生成的.Bundler将完全解决,以便正确处理原生宝石.这可能会导致您的应用中使用意外的gem版本.在极少数情况下,Bundler可能根本无法解析您的依赖项. https://devcenter.heroku.com/articles/bundler-windows-gemfile

您可以在Capistrano中执行类似的操作,使用一些自定义代码在Bundler任务运行之前删除Gemfile.lock(或者只是完全从源代码控制中删除Gemfile.lock).您还必须更改Bundler参数以删除该--deployment标志,否则当它看到Gemfile.lock丢失时它将失败.

或者您可以将开发环境切换到Mac或Linux,例如使用Linux VM进行开发.

推荐阅读
mylvfamily
这个屌丝很懒,什么也没留下!
DevBox开发工具箱 | 专业的在线开发工具网站    京公网安备 11010802040832号  |  京ICP备19059560号-6
Copyright © 1998 - 2020 DevBox.CN. All Rights Reserved devBox.cn 开发工具箱 版权所有