Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

require all gems in Gemfile in non-Rails app?

Tags:

bundler

gem

When we write Rails app it requires all the gems defined in Gemfile for us.

How to make a non-Rails app do this?

like image 667
Lai Yu-Hsuan Avatar asked Jun 24 '12 15:06

Lai Yu-Hsuan


People also ask

How do I install everything in 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. Save this answer.

What is require in Gemfile?

Gemfiles. Gemfiles require at least one gem source, in the form of the URL for a RubyGems server. Generate a Gemfile with the default rubygems.org source by running bundle init . If you can, use https so your connection to the rubygems.org server will be verified with SSL.

What is the difference between Gemfile and Gemfile lock?

The Gemfile is where you specify which gems you want to use, and lets you specify which versions. The Gemfile. lock file is where Bundler records the exact versions that were installed. This way, when the same library/project is loaded on another machine, running bundle install will look at the Gemfile.

What is gem in Gemfile?

A Gemfile describes the gem dependencies required to execute associated Ruby code. Place the Gemfile in the root of the directory containing the associated code. For instance, in a Rails application, place the Gemfile in the same directory as the Rakefile .


1 Answers

require 'rubygems'
require 'bundler'
Bundler.require(:default)

The above requires the gems in particular groups, noting that gems outside of a named group are in the :default group

See here: https://bundler.io/v2.0/guides/groups.html

like image 68
Andrei Navarro Avatar answered Sep 28 '22 03:09

Andrei Navarro