Where is the "Gemfile" in Ruby?

GluecklichesHuhn picture GluecklichesHuhn · May 30, 2016 · Viewed 22.6k times · Source

I often see in documentation on the Internet, "put this in the Gemfile". I don't know where and what this "Gemfile" is. If I install a gem then I have installed it. Who need than a "Gemfile"? Where or what is the Gemfile, and why is it used?

Answer

Weston picture Weston · May 30, 2016

The Gemfile is wherever you want it to be - usually in the main directory of your project and the name of the file is Gemfile.

It's convenient to have one because it allows you to use Bundler to manage which gems and which versions of each your project needs to run.

If you are not using Bundler (which you should!), then you can just install any gems you come across with gem install X and ignore instructions about adding a line to your Gemfile.

Read more about it here: