A much better of managing your gem dependencies
Switch branches/tags
Nothing to show
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Failed to load latest commit information.


Gemtronics – Simple and Smart Gem Management

Gemtronics is designed to mitigate the pain of gem management for your Ruby applications. It can be used with standalone Ruby libraries or in Rails applications, it doesn’t much matter to Gemtronics.


Gemtronics is, itself, a RubyGem. So yes, there is on dependency you have to have on your machine before you can use it to manage your other gems for your projects.

  $ sudo gem install gemtronics

Or, if you prefer to live on the edge:

  $ sudo gem install markbates-gemtronics --source=http://gems.github.com


Gemtronics comes bundled with a binary that can help make life a little nicer. The binary has three different options, generate, convert, and install.


Gemtronics will generate a sample file for you by using the binary, like such:

  $ gemtronics generate

That will output the following into a file called config/gemtronics.rb:

  group(:default) do |g|
    # g.add('gem name here')
    # g.add('gem name here', :version => '1.2.3')
    # g.add('gem name here', :version => '1.2.3', :source => 'http://gems.example.com')
    # g.add('gem name here', :version => '1.2.3', :source => 'http://gems.example.com', :require => ['file1', 'file2'])

  group(:production, :dependencies => :default) do |g|

  group(:development, :dependencies => :default) do |g|

  group(:test, :dependencies => :development) do |g|

If you don’t like that file path you can tell it where to generate the file for you:

  $ gemtronics generate path/to/my/file.rb

It is encouraged that you use the default path for your file, as it will make it easier for Gemtronics to find it later.


On the off chance you are using the old Gemtools project for managing your gems, Gemtronics can easily convert that old school YAML file to the Gemtronics format:

  $ gemtronics convert path/to/my/gems.yml


Once you have setup your Gemtronics file, more on that in a minute, you can use it to easily install your gems from it:

  $ gemtronics install

Gemtronics will read the config/gemtronics.rb and install all the gems in the :default group. If you would like to specify a different group you can do that like so:

  $ gemtronics install production

If you did not put your file in config/gemtronics.rb you will need to specify the path:

  $ gemtronics install default path/to/my/file.rb

Gemtronics will not install gems again if they already exist on your machine. This makes installation fast and easy!

Configuring Your Gems

Gemtronics has the concept that gems can be grouped. Why would you want to group your gems? Great question. Perhaps you have a default set of gems that you want to use with your application, you would put them in the default group. In testing and development you might want to include other gems, such as ruby-debug, that you wouldn’t want running/installed on your production machines. In this case you would group them in another group that depends on the default group.

Defining a group is very easy:

  group(:default) do |g|

When you add gems to a group you can set all the necessary gem options, or just inherit the default options. See the sample file below, or the rest of the RDOC for more information.


Right about now you’re saying to yourself, I use the Rails gem management system, why should I use this? Well, because the Rails gem management system is flawed at it’s very core. You define your gems in the environment, which means the environment must be loaded to load/install your gems. However, this cause blow up if a gem is not installed when it loads the environment. Plus, why would you want to load the environment just to install gems?

Gemtronics also has the advantage of being an independent system to Rails, which means that you can use it to install Rails for you!

To use with Rails just create a file named gemtronics.rb in your config directory, and load it up with your favorite gems.

Once you’ve set up your gems just add the following inside the initializer block in environment.rb (where you would normally call config.gem):

  require 'gemtronics'

Gemtronics will use the current RAILS_ENV to load the correct gem group. You can override this by passing in the :group option and specify which group you would like to use.


  group(:default) do |g|
    g.add('gem2', :version => '1.2.3')
    g.add('gem3', :source => 'http://gems.github.com')
    g.add('gem4', :require => 'gem-four')
    g.add('gem5', :require => ['gem-five', 'gemfive'])
    g.add('gem6', :load => false)

  group(:production, :dependencies => :default) do |g|
    g.add('gem3', :load => false)
    g.add('gem4', :source => 'http://gems.example.org')

  group(:development, :dependencies => :default) do |g|
    g.add('gem7', :version => '>=', :load => false, :require => 'gemseven')

  group(:test, :dependencies => :development, :source => 'http://gems.example.com') do |g|

  group(:staging) do |g|
    g.add('gem2', :version => '3.2.1')
    g.add('gem7', :load => true)