Ruby on Rails | Screencasts | Download | Documentation | Weblog | Community | Source

Ticket #11590 (new defect)

Opened 1 month ago

Last modified 1 month ago

Removing vendor Rails with Git causes cryptic error

Reported by: norbauer Assigned to: core
Priority: normal Milestone: 2.x
Component: ActiveRecord Version: edge
Severity: normal Keywords: tiny
Cc:

Description

Due to the content- (rather than directory- or file-) oriented nature of Git, if a user attempts to remove vendor/rails from his repository using

git rm -r vendor/rails

Git will remove all of the associated files, but leave leave a barren ghost-town of empty Rails directories intact, which may not be immediately apparent to the new Git user. This confuses boot.rb, which assumes (quite wrongly) that just because the vendor/rails directory is present, that Rails itself is present. This leads to the slightly cryptic error:

(in /Users/ryan/Sites/blah)
rake aborted!
no such file to load -- /Users/ryan/Sites/blah/config/../vendor/rails/railties/lib/initializer
/Users/ryan/Sites/blah/rakefile:4
(See full trace by running task with --trace)

whenever one attempts to run Rails or any of its rake tasks.

I have attached a patch that makes boot.rb check that initializer.rb actually exists (rather than just vendor/rails) before proceeding to try to load Rails. Now if vendor/rails exists but not the initializer, boot.rb will revert to loading the gem version of Rails (a contingency which is also tested.)

No doc updates necessary. Associated tests updated, pass.

Attachments

check_that_vendor_rails_actually_exists_rather_than_just_its_directory.diff (1.5 kB) - added by norbauer on 04/14/08 13:33:52.

Change History

04/14/08 13:33:52 changed by norbauer

  • attachment check_that_vendor_rails_actually_exists_rather_than_just_its_directory.diff added.

04/14/08 14:20:01 changed by norbauer

If anybody thinks it's a good idea, we could also add a console warning if somebody is trying to load Rails with an empty vendor/rails directory.

It's probably a good idea to have something exceptional happen when vendor/rails is empty, but my point with this patch is merely that that something shouldn't be exploding without explaining very specifically why.

When I see "no such file to load -- /Users/ryan/Sites/blah/config/../vendor/rails/railties/lib/initializer", I think "well yeah, that's because I just delete vendor/rails." Since most people like to exclude vendor/rails from their textmate drawer, it further obscures the root of the problem.