最近将Travis-CI和Coveralls整合到一个github回购中之后,我无法让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!
显然它不是安装rest-client,而是我的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与我自己之间唯一明显的区别是我的宝石版本是2.2.2而捆绑版本是1.7.12
我不明白的是为什么Travis在应该自动化我的测试时传递--deployment标志 - 不应该在测试环境中吗?无论如何,当我在自己的机器上bundle install --deployment
时,仍然安装了rest-client 1.7.2,这与Travis不同。
如何确保安装rest-client?
答案 0 :(得分:1)
问题是windows上的bundler正在为Gemfile.lock文件添加特定于平台的后缀,告诉Travis(在linux系统上运行)不要打扰gem。解决方案(无论如何应该是这种情况)是git rm Gemfile.lock
并将其添加到.gitignore文件中。在项目中使用Gemfile就足够了。