Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Why use GemSpec + GemFile when checking for dependencies?

Whenever developing gems, I don't see any reasons why Gemfile is not directly inspected for dependencies.

Indeed, why use a .gemspec file in order to list them ? Is there a real benefit ?

like image 487
Mik378 Avatar asked Jul 02 '12 20:07

Mik378


People also ask

What is Gemfile used for?

A Gemfile is a file that is created to describe the gem dependencies required to run a Ruby program. A Gemfile should always be placed in the root of the project directory.

What is Gemspec in Gemfile?

Gemspec is basically the Readme for gems. It tells you about the author, version, summary, description, internal dependencies, execution and everything about the Gem. So now it was easy to use gems as all of them were having their specifications with them.

Should you check in Gemfile lock?

Pretty much everyone agrees you should check that into git. Including your Gemfile. lock in version control is standard practice if you are writing an application.

Where do I put 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

Well that's because the Gemfile isn't a file from Rubygems, but a file from Bundler. So the Rubygem developers would have to extend their used files in order to support Gemfile. Since there already is the .gemspec file, there is no valid reason why they should. (there are enough gems which do well without a Gemfile)

In fact, it is recommended to use this as the only contents of the Gemfile of gems:

source 'https://rubygems.org'
gemspec

It will instruct bundler to use the .gemspec file as the authorative source of gems.

like image 184
robustus Avatar answered Sep 28 '22 19:09

robustus