LoginSignup
1

More than 5 years have passed since last update.

Travis で複数のアプリで bundle install したい

Posted at

Travis のビルド時に別のアプリに cd して bundle install しようとしても、もともとのビルド対象の Gemfeil を見にいってしまって、意図通りに動かない事がある。それを解決したのでメモ。

問題

具体的にはこんな感じのディレクトリ構成で、

my_rails_app
  |
  +- mock_rails_app/

テストを実行する前に Rails.root 直下にあるモックの Rails アプリを動かしたい。
spec_helper.rb でテスト実行前に起動してテスト実行後に殺すようにしてるが、動かす前には bundle install しておきたいので travis.yml にはこんな感じで書いておいた。

before_script:
  - pushd mock_rails_app && bundle install && popd

で、これがうまく動かない。
mock_rails_appcd してるはずなのに、my_rails_app 直下の Gemfile を見にいってしまっているらしい。

解決方法

これを解決するには、こう書くと良かった。

before_script:
  - pushd mock_rails_app && BUNDLE_GEMFILE=$(pwd)"/Gemfile" bundle install && popd

Budnler は環境変数 BUNDLE_GEMFILE で指定された Gemfile を見に行くらしい。

Travis は実行前に BUNDLE_GEMFILE を設定してあったりするのだろうか…

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
1