Skip to content
This repository has been archived by the owner on Nov 19, 2020. It is now read-only.

Bundler

Christian Meier edited this page Jan 7, 2014 · 4 revisions

Nexus Rubygems server and Bundler

Bundler is very popular tool for managing the gem dependency of a project/library. in order to use for example a proxy to rubygems.org you would need to replace inside the Gemfile the source 'https://rubygems.org' declaration to use the url of your proxy. Bundler itself has no notion of mirror to rubygems repository. such a mirror feature which would be the ideal to keep all the Gemfiles as they are and still allow Bundler to use the proxy.

with a small monkey patch to bundler such mirror support can be added. this is part of the nexus gem. but it the past that patch broke once or twice with newer bundler versions - so it is crud workaround.

bundler from nexus gem (obsolete with bundler-1.5.0)

NOTE: the bundler monkey patch from the nexus gem is not needed anymore from bundler version 1.5.0 onwards !!! bundler has the mirror support built in now.

we need a way to tell bundler to use the nexus proxy or nexus group instead of the orginal source. for the time being Bundler itself does not have that support. but the nexus gem adds a nbundle command to your ruby environment which is a very thin wrapper around bundle added mirror support to bundler:

gem install nexus

adding a mirror to Bundler

bundle config mirror.http://rubygems.org http://localhost:8081/nexus/content/repositories/rubygems
bundle config mirror.https://rubygems.org http://localhost:8081/nexus/content/repositories/rubygems

or with the nbundle command

nbundle config mirror.{URL_OF_RUBYGEMS_REPOSITORY} {URL_OF_NEXUS_RUBYGEMS_REPOSITORY}

NOTE: you can either use bundle or nbundle to configure the mirror but only nbundle or bundler >= 1.5.0 will use it.

now whenever you use nbundle in the same manner as bundle you will use the mrror-url instead of the original urls.

example (assume bundler >= 1.5.0)

  • using a nexus proxy to rubygems.org
  • cloning a project with Gemfile
  • install the gems with bundler using the nexus proxy

configure Bundler

bundle config mirror.http://rubygems.org http://localhost:8081/nexus/content/repositories/rubygems/

get the project some project, i.e. virtus

git clone virtus

install the gems

cd virtus
bundle install

schedule tasks for bundler-API

the bundler API of the nexus repositories uses the gemspec files from quick/Marshal.4.8/* to respond to the bundler API requests. this can leads to timeouts on the bundler side since first all the gemspec files needs to be cached locally. once they are all cached the nexus repository delivers fast respondses. to help bundler updates and further bundler request there is a schduled task Update Bundler API Dependencies to keep the already used dependencies cache uptodate, i.e. no further gemspec downloads are needed for those dependencies.

a daily update is a good choice.