sren
sren

Reputation: 3623

Add gem to gemfile with bundler from command line

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

Upvotes: 71

Views: 52686

Answers (4)

lesterzone
lesterzone

Reputation: 243

as @zocoi described, you can use bundle and specify the group:

bundle add rails --group "development, test"

More information

bundle add --help

Upvotes: 12

zocoi
zocoi

Reputation: 1200

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 ~

Upvotes: 86

Dru
Dru

Reputation: 9820

Just wrote Gemrat to do this.

    $ gem install gemrat 
    $ gemrat nokogiri

    #=> gem 'nokogiri', '1.6.0' added to your Gemfile.
    #=> Bundling...

Upvotes: 50

dj2
dj2

Reputation: 9598

echo 'gem "nokogiri"' >> Gemfile

Upvotes: 25

Related Questions