Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Add gem to gemfile with bundler from command line

Tags:

ruby

bundler

gem

When using node package manager you can specify npm install --save mynodemodule which automatically pops the module in package.json

I was wondering if there is a command for bundler that allows you to add the gem and version to the gemfile from the command line?

For example bundle install --save nokogiri

like image 998
sren Avatar asked Nov 04 '11 05:11

sren


People also ask

How do you install gems you added to your Gemfile?

run the command bundle install in your shell, once you have your Gemfile created. This command will look your Gemfile and install the relevant Gems on the indicated versions. The Gemfiles are installed because in your Gemfile you are pointing out the source where the gems can be downloaded from.


2 Answers

If you visit this question in 2018, bundler now has a cli to do this: bundle add <gem-name> <version>

Version string could be your typical gem version including >= and ~

like image 98
zocoi Avatar answered Oct 09 '22 03:10

zocoi


Just wrote Gemrat to do this.

    $ gem install gemrat      $ gemrat nokogiri      #=> gem 'nokogiri', '1.6.0' added to your Gemfile.     #=> Bundling... 
like image 30
Dru Avatar answered Oct 09 '22 01:10

Dru