53

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?

jcubic
  • 61,973
  • 54
  • 229
  • 402

2 Answers2

80

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
end
Sergioet
  • 1,108
  • 13
  • 27
  • Thank you for the hint! Do you know how can I set gem / bundle to always work on local packages not the system ones? :-) – CeDeROM May 14 '23 at 17:58
  • 1
    Does this help? https://stackoverflow.com/questions/4487948/how-can-i-specify-a-local-gem-in-my-gemfile – Sergioet May 22 '23 at 08:43
35

First install bundler if you don't have it

gem install bundler or sudo gem install bundler if you don't have the required permissions. Bundler is a gem that manages gem dependencies.

then you can follow the above instruction for creating the gemfile, after which you can issue the command

bundle install

briankip
  • 2,502
  • 2
  • 23
  • 26