Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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?

like image 872
jcubic Avatar asked Jun 12 '16 17:06

jcubic


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.

How do I install gems?

To install a gem, use gem install [gem] . Browsing installed gems is done with gem list . For more information about the gem command, see below or head to RubyGems' docs. There are other sources of libraries though.


2 Answers

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 
like image 168
Sergioet Avatar answered Sep 27 '22 22:09

Sergioet


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

like image 23
briankip Avatar answered Sep 27 '22 22:09

briankip