Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

In Ruby on Rails, why is "bundle install" so slow to create Gemfile.lock and "rails g foo name:string" creates it so quickly?

I already have all the gems, and each time I do

rails trytry02
cd trytry02
bundle install

to create the Gemfile.lock, it takes a long time to fetch data from rubygems.org. But I noticed that if I do a

rails g scaffold foo name:string

before doing the bundle install, then the Gemfile.lock is created very fast. Is there a way to create it fast but not using rails g scaffold?

like image 640
nonopolarity Avatar asked Apr 14 '11 12:04

nonopolarity


People also ask

Is Gemfile lock automatically generated?

A Gemfile. lock is auto-generated & it says exactly what versions of every gem were installed. Bundler will install these versions so when you deploy this application to production, or share your project with other developers, everyone will be working with an identical set of gems.

What is 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.

When Gemfile lock is created?

3 after running bundle install , and the app would be working for him. Important! Gemfile. lock is automatically generated when you run bundle install or bundle update .

What is Gemfile in Ruby on Rails?

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.


1 Answers

Douglas is correct, this is because bundle install is doing a round trip to rubygems.org to look for newer versions. If you want to just use the local versions...

bundle install --local

But - why are you generating your Gemfile.lock so often that this is an issue? Your Gemfile.lock should be under version control, ie. part of your project, and so should only change occasionally.

like image 191
smathy Avatar answered Jan 05 '23 03:01

smathy