Save a Gem to Gemfile From Terminal

| Comments

Have you ever wished you could save a gem to your Gemfile straight from the command line? I wish Rubygems had this built in, but it’s easy to add. After all, there’s a gem for that.

Gemrat

From npm

Coming from Node/Npm previous to Ruby/Rubygems, I wished I could do something like this:

1
npm install express --save

This would take my specified npm module and append it to the end of my package.json dependencies list.

There is no equivalent for this built into Rubygems.

Gemrat

But, there is a mutant beast that skulks through the gem-lined sewers of Rubyland – and it’s name is gemrat! What a great, image-provoking name. Once you install gemrat, you will have the power of 20 npms at your fingertips.

First, install it:

1
gem install gemrat

Next, decide what gem you want to save to your Gemfile. Let’s choose a gem of a gem to try called guard:

1
gemrat guard

Now, install the dependencies listed in your Gemfile:

1
bundle install

Kaboom. You have learned the secrets of the Fire Swamp and could live there for some time.

Comments