jcubic jcubic - 4 months ago 12x
Ruby Question

How to install gems from Gemfile?

I want to add code coverage to my project and sign up coveralls.io and create Gemfile with:

gem 'coveralls', require: false

but how can I install the gem from 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.

Your can create a Gemfile just by typing bundle init in your shell

I add a Gemfile example for your reference:

source "https://rubygems.org"  # where gems will be downloaded from
ruby "2.2.3"  # ruby version, change for the one you use

gem "sinatra"
gem "sinatra-flash"
gem "sinatra-partial"
gem "bcrypt"
gem "dm-validations"
gem "dm-transactions"
gem "data_mapper"
gem "dm-postgres-adapter"
gem "pg"
gem "database_cleaner"

group :test do   # you can make groups for test, development, production..
  gem "rspec"
  gem "capybara"
  gem "rspec-sinatra"
  gem "cucumber"
  gem "coveralls", require: false