Breedly Breedly - 6 months ago 20
Ruby Question

Tar a bundler project and send to another system

I have two systems that use the same command line interface written in ruby. One system is using an older version that's incompatible with the scripts we have written. We'd like to use bundler to download all the dependencies for the

2.0
on our own system, and then migrate that
bundle
over to the system with the older version so that we can use
2.0
there as well.

We do not have the option to run
bundle install
on the other system because it's not open to the internets.


So the idea is on my system:

bundle init


...write
Gemfile
...

bundle install


tar -czf cli2.0.tar.gz ./Gemfile ./Gemfile.lock ./.bundle ./bundle


... move
cli2.0.tar.gz
to the other system ...

On system B:

tar -zxf cli2.0.tar.gz


bundle exec cli2.0 version


But at this point we get an error stating that
bundler
couldn't find any of the gems even though they're right there under
./bundle/ruby/2.3.0/
!!

It looks like they have different versions of
ruby
, and
ruby-gems
installed.

Answer

Received some help from a coworker, the gist is I was doing it all wrong.

If you want to transport gems and see consistent performance with bundler do this.

  1. bundle install <gem>
  2. bundle package
    • This creates a cache of the downloaded gems for transport.
  3. tar -czf ./transport.tar.gz ./Gemfile ./Gemfile.lock ./vendor

On the next machine:

  1. tar -xzf ./transport.tar.gz
  2. bundle exec <command>