任何捆绑命令都会清除 Gemfile.lock 文件内容

Any bundle command clears out Gemfile.lock file content

目前的Gemfile.lock是这样的:

GIT
  remote: git://github.com/collectiveidea/awesome_nested_set.git
  revision: 57bada268cbca6cdc7dd3656d943ef1b76fbc3c0
  specs:
    awesome_nested_set (3.0.1)
      activerecord (>= 4.0.0, < 5)

GIT
  remote: git://github.com/plataformatec/simple_form.git
  revision: a28012bf2f2aa6dabd2b1efd5a306279cb3c885e
  specs:
    simple_form (3.1.0)
      actionpack (~> 4.0)
      activemodel (~> 4.0)

GEM
  remote: https://rubygems.org/
  remote: https://rails-assets.org/
  specs:
    actionmailer (4.2.0)
      actionpack (= 4.2.0)
      actionview (= 4.2.0)
      activejob (= 4.2.0)
      mail (~> 2.5, >= 2.5.4)
      rails-dom-testing (~> 1.0, >= 1.0.5)
    actionpack (4.2.0)
      actionview (= 4.2.0)
      activesupport (= 4.2.0)
      rack (~> 1.6.0)
      rack-test (~> 0.6.2)
      rails-dom-testing (~> 1.0, >= 1.0.5)
      rails-html-sanitizer (~> 1.0, >= 1.0.1)
    actionview (4.2.0)
      activesupport (= 4.2.0)
      builder (~> 3.1)
      erubis (~> 2.7.0)
      rails-dom-testing (~> 1.0, >= 1.0.5)
      rails-html-sanitizer (~> 1.0, >= 1.0.1)
    activejob (4.2.0)
      activesupport (= 4.2.0)
      globalid (>= 0.3.0)
    activemodel (4.2.0)
      activesupport (= 4.2.0)
      builder (~> 3.1)
    activerecord (4.2.0)
      activemodel (= 4.2.0)
      activesupport (= 4.2.0)
      arel (~> 6.0)
    activesupport (4.2.0)
      i18n (~> 0.7)
      json (~> 1.7, >= 1.7.7)
      minitest (~> 5.1)
      thread_safe (~> 0.3, >= 0.3.4)
      tzinfo (~> 1.1)
    rails-assets-caman (4.1.2)
    rails-assets-classie (1.0.1)
    rails-assets-cssfx (0.9.6)
    rails-assets-doc-ready (1.0.4)
      rails-assets-eventie (>= 1, < 2)
    rails-assets-embedly-jquery (3.1.2)
    rails-assets-enquire (2.1.2)
    rails-assets-eventEmitter (4.2.11)
    rails-assets-eventie (1.0.6)
    rails-assets-fizzy-ui-utils (1.0.1)
      rails-assets-doc-ready (~> 1.0.4)
      rails-assets-matches-selector (~> 1.0.2)
    rails-assets-get-size (1.2.2)
      rails-assets-get-style-property (~> 1.0)
    rails-assets-get-style-property (1.0.4)
    rails-assets-imagesloaded (3.1.8)
      rails-assets-eventEmitter (~> 4.0)
      rails-assets-eventie (>= 1.0.4, < 2)
    rails-assets-iscroll (5.1.2)
    rails-assets-jquery (2.1.4)
    rails-assets-jquery-bridget (1.1.0)
      rails-assets-jquery (>= 1.4.2, < 3)
    rails-assets-jquery-deserialize (1.3.1)
      rails-assets-jquery (>= 1.4.3)
    rails-assets-jquery-hoverIntent (1.8.1)
      rails-assets-jquery (>= 1.9.1)

PLATFORMS
  ruby

DEPENDENCIES
  annotate
  awesome_nested_set!
  bcrypt    
  quilt
  rack-attack
  rails (= 4.2)!
  rails-assets-caman!
  rails-assets-cssfx!
  rails-assets-embedly-jquery!
  rails-assets-enquire!
  rails-assets-imagesloaded!
  rails-assets-iscroll (= 5.1.2)!
  rails-assets-jquery-bridget!
  rails-assets-jquery-deserialize!
  rails-assets-jquery-hoverIntent!
  rails-assets-jquery-infield-label!
  rails-assets-jquery.caro!
  rails-assets-jquery.center.js!

运行 bundlebundle install 只是删除整个 Gemfile.lock 内容并保留如下:

GEM
  remote: https://rubygems.org/
  remote: https://rails-assets.org/
  specs:

PLATFORMS
  ruby

DEPENDENCIES

捆绑命令的输出:

The Gemfile specifies no dependencies
Resolving dependencies...
Your bundle is complete!
It was installed into ./vendor/bundle

为什么会这样?

Bundler 版本(1.6.2 很旧)及其配置有问题,只需删除配置并更新 bundler:

cd app_dir
rm -v .bundle/config
gem update bundler
bundle install

在发出最后一个命令之前确保 Gemfile 语法正确。