0

在最近为 github 存储库集成 Travis-CI 和 Coveralls 之后,我无法让 Travis 正确构建。我收到此错误:

$ ruby --version
ruby 2.1.5p273 (2014-11-13 revision 48405) [x86_64-linux]
$ rvm --version
rvm 1.26.8 (latest-minor) by Wayne E. Seguin <wayneeseguin@gmail.com>, Michal Papis <mpapis@gmail.com> [https://rvm.io/]
$ bundle --version
Bundler version 1.7.6
$ gem --version
2.4.5
install.bundler
5.06s$ bundle install --jobs=3 --retry=3 --deployment
Fetching gem metadata from http://rubygems.org/..........
Installing multi_json 1.10.1
Installing docile 1.1.5
Installing simplecov-html 0.8.0
Installing tins 1.3.3
Installing thor 0.19.1
Using bundler 1.7.6
Installing rake 10.4.2
Installing simplecov 0.9.1
Installing term-ansicolor 1.3.0
Installing coveralls 0.7.8
Your bundle is complete!
It was installed into ./vendor/bundle
0.80s$ bundle exec rake
/home/travis/.rvm/rubies/ruby-2.1.5/bin/ruby test/unit_test.rb
/home/travis/build/devonparsons/ruby-tricks/vendor/bundle/ruby/2.1.0/gems/coveralls-0.7.8/lib/coveralls/api.rb:5:in `require': cannot load such file -- rest_client (LoadError)
from /home/travis/build/devonparsons/ruby-tricks/vendor/bundle/ruby/2.1.0/gems/coveralls-0.7.8/lib/coveralls/api.rb:5:in `<class:API>'
from /home/travis/build/devonparsons/ruby-tricks/vendor/bundle/ruby/2.1.0/gems/coveralls-0.7.8/lib/coveralls/api.rb:2:in `<module:Coveralls>'
from /home/travis/build/devonparsons/ruby-tricks/vendor/bundle/ruby/2.1.0/gems/coveralls-0.7.8/lib/coveralls/api.rb:1:in `<top (required)>'
from /home/travis/build/devonparsons/ruby-tricks/vendor/bundle/ruby/2.1.0/gems/coveralls-0.7.8/lib/coveralls.rb:3:in `require'
from /home/travis/build/devonparsons/ruby-tricks/vendor/bundle/ruby/2.1.0/gems/coveralls-0.7.8/lib/coveralls.rb:3:in `<top (required)>'
from test/unit_test.rb:3:in `require'
from test/unit_test.rb:3:in `<main>'
rake aborted! 

显然它没有安装其余客户端,但我的 Gemfile.lock(在尝试修复它之后,我的 Gemfile)都指定了它:

source 'http://rubygems.org'
gem 'coveralls', require: false
gem 'rest-client'
gem 'rake'

Gemfile.lock:

GEM
  remote: http://rubygems.org/
  specs:
    coveralls (0.7.8)
      multi_json (~> 1.10)
      rest-client (~> 1.7)
      simplecov (~> 0.9.1)
      term-ansicolor (~> 1.3)
      thor (~> 0.19.1)
    docile (1.1.5)
    ffi (1.9.6-x64-mingw32)
    mime-types (2.4.3)
    multi_json (1.10.1)
    netrc (0.10.2)
    rake (10.4.2)
    rest-client (1.7.2-x64-mingw32)
      ffi (~> 1.9)
      mime-types (>= 1.16, < 3.0)
      netrc (~> 0.7)
    simplecov (0.9.1)
      docile (~> 1.1.0)
      multi_json (~> 1.0)
      simplecov-html (~> 0.8.0)
    simplecov-html (0.8.0)
    term-ansicolor (1.3.0)
      tins (~> 1.0)
    thor (0.19.1)
    tins (1.3.3)

PLATFORMS
  x64-mingw32

DEPENDENCIES
  coveralls
  rake
  rest-client

Travis 的 env 和我自己的唯一显着区别是我的 gem 版本是 2.2.2,bundler 版本是 1.7.12

我不明白的是,为什么 Travis 在应该自动化我的测试时通过 --deployment 标志 - 它不应该在测试环境中吗?无论如何,当我bundle install --deployment在自己的机器上时,仍然安装了 rest-client 1.7.2,这与 Travis 不同。

我该怎么做才能确保安装了 rest-client?

4

1 回答 1

1

问题是 Windows 上的 bundler 正在向 Gemfile.lock 文件添加特定于平台的后缀,告诉 Travis(在 linux 系统上运行)不要打扰 gem。解决方案(无论如何应该是这种情况)是git rm Gemfile.lock将其添加到 .gitignore 文件中。项目中有 Gemfile 就足够了。

于 2015-01-30T05:26:10.380 回答