Multiple Rails engines bundle install error

Hi,
We have a Rails app with 2 engines.
Those engines require each others like this:
engine_1 is independent.
engine_2 requires engine_1.
The app requires both engines.
We have test in /spec/dummy from each engine’s folders.

About 2 days ago, suddenly, our builds failed from the migration step of engine_1/spec/dummy.
We saw that it asked for some environment variables from engine_2.
Then we recognized the error started from bundle install step.
Our config looks like this:

      - run:
          name: bundle rails_app
          command: cd rails_app && bundle install

      - run:
          name: bundle engine_1/spec/dummy
          command: cd engine_1/spec/dummy && bundle install
      - run:
          name: bundle engine_2/spec/dummy
          command: cd engine_2/spec/dummy && bundle install

Instead of using its own gems, the second bundle install command reuses every gems used by the first, including engine_2.
We have tried swapping the order but still, only the first bundle install has effect. The other 2 just copied the first one.

Here we stuck. Do you have any recommendation for this issue?
Thank you.

We have solved this!
It was an error from Bundler.
CircleCI uses latest version which is 1.16.0 which have some bugs when resolving gems.
We use version 1.15.4 and it’s fine.

Hello @peara,

Have you tried with Bundler 1.16.1 yet? There was some bugs fixed in the release which may solve this issue. I’d like to confirm.

Thanks!

@zzak
I think it hasn’t been fixed yet.
For some reason Bundler decided to install gems in a common folder instead of app folder, which causes all apps to share the same installed gems.