$ bin/rails -v Rails 5.2.0.rc1
/Rails5のアプリケーションでWerckerを使ってCIを利用としたところ、bin/rails testしたところで以下のようなエラーが発生しました。
/usr/local/lib/ruby/site_ruby/2.4.0/bundler/spec_set.rb:88:in `block in materialize': Could not find rake-12.3.0 in any of the sources (Bundler::GemNotFound)
bundle install は成功しているのになぜかrakeが見つからないと言われてしまいます。
wercker.ymlの設定は以下のようになっています。(一部省略)
box: ruby:2.4.3
services:
- id: mysql
env:
MYSQL_ROOT_PASSWORD: root_password
MYSQL_USER: test_user
MYSQL_PASSWORD: test_password
MYSQL_DATABASE: test_database
build:
steps:
- install-packages:
name: Install build-essential
packages: build-essential
- script:
name: install node
code: |
curl -sL https://deb.nodesource.com/setup_7.x | sudo bash -
sudo apt-get install -y nodejs
- script:
name: install yarn
code: |
curl -sS https://dl.yarnpkg.com/debian/pubkey.gpg | sudo apt-key add -
echo "deb https://dl.yarnpkg.com/debian/ stable main" | sudo tee /etc/apt/sources.list.d/yarn.list
sudo apt-get update && sudo apt-get install yarn
- bundle-install:
jobs: 4
- script:
name: install npm packages
code: bin/yarn
- rails-database-yml
- create-file:
name: write master.key
filename: ./config/master.key
overwrite: true
hide-from-log: true
content: $WERCKER_MASTER_KEY
- script:
name: Set up db
code: |
RAILS_ENV=test bin/rails db:schema:load
- script:
name: Run Test
code: bin/rails test
原因はどうやらbinstubsの内容と実際に実行ファイルが置かれている場所が異なるからのようです。
そこでbundle-installステップの後にbinstubsを更新するコマンドを追加します。
- script:
name: Update bin
code: bin/rails app:update:bin
これで無事にテストが実行されるようになりました。