2016-02-23 81 views
1

我試圖使用Circleci持續集成和運行成爲一個問題。我正在部署使用ruby 2.2.2和rspec的rails 4應用程序。circleci持續集成Rails應用程序錯誤需要條紋

當我試圖通過circleci把我的第一次構建,我得到一個錯誤,當它試圖運行我的代碼行測試套件在我的「spec_helper」我在哪裏需要帶寶石。我用條紋在該應用中,用「條紋模擬」

測試它下面的錯誤是。所以失敗是我在spec_helper中的require "stripe"行。要清楚rspec運行並通過本地,但我在circleci上得到這個錯誤。我加倍檢查,並設置了circleci上的所有環境變量。我聽說有時候寶石需要在circleci上設置的二進制文件才能工作。這可能是問題嗎?我將如何做到這一點?

rspec 
/home/ubuntu/.rvm/rubies/ruby-2.2.2/lib/ruby/site_ruby/2.2.0/rubygems/core_ext/kernel_require.rb:54:in `require': cannot load such file -- stripe (LoadError) 
from /home/ubuntu/.rvm/rubies/ruby-2.2.2/lib/ruby/site_ruby/2.2.0/rubygems/core_ext/kernel_require.rb:54:in `require' 
from /home/ubuntu/propel/spec/spec_helper.rb:20:in `block in <top (required)>' 
from /home/ubuntu/.rvm/gems/[email protected]/gems/rspec-core-3.4.1/lib/rspec/core.rb:97:in `configure' 
from /home/ubuntu/propel/spec/spec_helper.rb:18:in `<top (required)>' 
from /home/ubuntu/.rvm/rubies/ruby-2.2.2/lib/ruby/site_ruby/2.2.0/rubygems/core_ext/kernel_require.rb:54:in `require' 
from /home/ubuntu/.rvm/rubies/ruby-2.2.2/lib/ruby/site_ruby/2.2.0/rubygems/core_ext/kernel_require.rb:54:in `require' 
from /home/ubuntu/.rvm/gems/[email protected]/gems/rspec-core-3.4.1/lib/rspec/core/configuration.rb:1295:in `block in requires=' 
from /home/ubuntu/.rvm/gems/[email protected]/gems/rspec-core-3.4.1/lib/rspec/core/configuration.rb:1295:in `each' 
from /home/ubuntu/.rvm/gems/[email protected]/gems/rspec-core-3.4.1/lib/rspec/core/configuration.rb:1295:in `requires=' 
from /home/ubuntu/.rvm/gems/[email protected]/gems/rspec-core-3.4.1/lib/rspec/core/configuration_options.rb:109:in `block in process_options_into' 
from /home/ubuntu/.rvm/gems/[email protected]/gems/rspec-core-3.4.1/lib/rspec/core/configuration_options.rb:108:in `each' 
from /home/ubuntu/.rvm/gems/[email protected]/gems/rspec-core-3.4.1/lib/rspec/core/configuration_options.rb:108:in `process_options_into' 
from /home/ubuntu/.rvm/gems/[email protected]/gems/rspec-core-3.4.1/lib/rspec/core/configuration_options.rb:21:in `configure' 
from /home/ubuntu/.rvm/gems/[email protected]/gems/rspec-core-3.4.1/lib/rspec/core/runner.rb:101:in `setup' 
from /home/ubuntu/.rvm/gems/[email protected]/gems/rspec-core-3.4.1/lib/rspec/core/runner.rb:88:in `run' 
from /home/ubuntu/.rvm/gems/[email protected]/gems/rspec-core-3.4.1/lib/rspec/core/runner.rb:73:in `run' 
from /home/ubuntu/.rvm/gems/[email protected]/gems/rspec-core-3.4.1/lib/rspec/core/runner.rb:41:in `invoke' 
from /home/ubuntu/.rvm/gems/[email protected]/gems/rspec-core-3.4.1/exe/rspec:4:in `<top (required)>' 
from /home/ubuntu/.rvm/gems/[email protected]/bin/rspec:23:in `load' 

from /home/ubuntu/.rvm/gems/[email protected]/bin/rspec:23:in `<main>' rspec returned exit code 1 

我也應該注意到,我有帶我的Gemfile,你可以在這裏看到:

gem 'stripe' 

而且你能看到我在rspec的spec_helper要求條紋在這裏:

RSpec.configure do |config| 

require 'stripe' 
require 'stripe_mock' 
require 'thin' 

儘管在我的gemfile中有條紋,但我決定嘗試將sudo gem install stripe添加到我的circle.yml文件中,以確保它包含在測試中,但出現以下錯誤:

sudo gem install stripe 
ERROR: Error installing stripe: 

sudo gem install stripe returned exit code 1 

mime-types requires Ruby version >= 1.9.2. Action failed: sudo gem install stripe 

當我指定我circle.yml文件紅寶石版本2.2.2

+0

你有一個的Gemfile?它是條紋寶石嗎?最好能夠證明這一點。也最好顯示spec_helper的相關位。 –

+0

哎@DaveSchweisguth - 我的gemfile裏有條紋寶石。我已經使用該信息和相關的spec_helper代碼更新了我的答案。 –

回答

0

而不是增加sudo gem install stripecircle.yml文件,這甚至,你應該添加gem stripeGemfile

CircleCI documentation說:

In all likelihood, you'll have a list of libraries and dependencies that your app requires. CircleCI automatically detects Ruby's Gemfile, … and then runs the appropriate commands to install the dependencies.

如果您還沒有一個Gemfile,您可以:

  1. 運行gem install bundler
  2. 創建Gemfile列出你的應用程序需要運行,包括stripe RubyGems的。它應該是這個樣子:

    source "https://rubygems.org" 
    gem "stripe" 
    
  3. 運行bundle命令。這應該創建一個Gemfile.lock文件,列出您使用的相互兼容的寶石的特定版本。

  4. 提交機器人的GemfileGemfile.lock你的版本控制系統。

Bundler Web site還有很多information about Gemfiles

+0

感謝您伸出@georgebrock - 我有一個帶有條紋的寶石文件。我用一些格式更新了我的答案,並添加了一些更相關的代碼。 –

相關問題