Lighthouse has a new layout. Prefer the old one? Return to the old layout, and switch back any time from the link at the top of each page.

This project is archived and is in readonly mode.

Increase error message output in boot.rb

#2901

I received a message stating that rails was not installed. It was:

[wwalker@silver ~]$ list_processor Missing the Rails 2.2.2 gem. Please gem install -v=2.2.2 rails, update your RAILS_GEM_VERSION setting in config/environment.rb for the Rails version you do have installed, or comment out RAILS_GEM_VERSION to use the latest version installed.
[wwalker@silver ~]$ gem list rails

LOCAL GEMS

rails (2.2.2)

I spent about 2 hours trying to sort this out. Finally I added one line
to boot.rb (after adding debug code a multitude of other places, and running strace, etc.):

[wwalker@silver ~] diff --git a/config/boot.rb b/config/boot.rb index 6a30b54..e0c6e29 100644
--- a/config/boot.rb +++ b/config/boot.rb @@ -62,6 +62,7 @@ module Rails

   end
 rescue Gem::LoadError => load_error
   $stderr.puts %(Missing the Rails #{version} gem. Please `gem install -v=#{version} rails`, update your RAILS_GEM_VERSION setting in config/environment.rb for the Rails version you do have installed, or comment out RAILS_GEM_VERSION to use the latest version installed.)
  • $stderr.puts load_error exit 1 end

This immediately told me that rails 2.2.2 would not load because
activesupport 2.3.2 was already active. That is my problem to solve,
but this one extra line of output would shorten the troubleshooting phase
for a lot of people when they have a problem loading rails although it
is installed.

Reported by ronin-9952 (at lighthouseapp) · July 11th, 2009 @ 05:05 PM

State: committed
Milestone: 2.3.9
Assigned to: José Valim José Valim
Importance: none

Activity

  1. Jeremy Kemper
    Jeremy Kemper
    • Milestone changed from 2.x to 3.x

    May 4th, 2010 @ 06:48 PM

  2. David Trasbo
    David Trasbo
    • Assigned user set to José Valim
    • Importance changed from to

    A better solution is to simply re-raise the Gem::LoadError. I've attached a patch that does just that.

    Other than that I definitely think it's a useful change. Pre-Bundler I often spent hours debugging the cause of this often in-sufficient/vague error message.

    June 27th, 2010 @ 01:06 PM

  3. José Valim
    José Valim
    • Milestone changed from 3.x to 2.3.9

    I think that showing the install rails 2.2.2 when it is already installed is confusing in any occasion. So, ideally, we should check the reason the gem failed loading and if the reason is because it's really missing, we show the current message, otherwise, we simply re-raise the original error.

    June 27th, 2010 @ 01:28 PM

  4. David Trasbo
    David Trasbo

    Definitely a good point. I've attached another patch that tells the user that the Rails gem is missing if that's the case, otherwise it simply re-raises the Gem::LoadError.

    June 29th, 2010 @ 10:13 AM

  5. Lenary
    Lenary

    David, just had a look at that patch,

    you might want to re-examine the regular expression. what if the list of unfound rubygems is longer than rails, and there is something between the "Could not find RubyGem" and the word rails.

    This said, i don't know if that could ever happen...

    June 29th, 2010 @ 10:32 AM

  6. David Trasbo
    David Trasbo

    I see your point, but basically: No, it can't. :)

    Sure, one of the dependencies (activesupport, actionpack, etc.) could be missing, but if the Rails gem itself is missing the code will not know it, because the dependencies are defined within the Rails gem.

    You can try it by installing Rails (version 2.2.2, for example, doesn't really matter), uninstall the Rails gem itself and one or more of the dependencies. The Gem::LoadError message will be the same, because it's unaware of which gems Rails depends on and therefore doesn't care if they're installed.

    June 29th, 2010 @ 10:44 AM

  7. Repository
    Repository
    • State changed from new to committed

    (from [d0d10f51d7b2edea94a00291d79cad769d8a6470]) Only tell users that the Rails gem is missing if it's actually the case [#2901 state:committed]

    Signed-off-by: José Valim jose.valim@gmail.com
    http://github.com/rails/rails/commit/d0d10f51d7b2edea94a00291d79cad...

    June 29th, 2010 @ 04:55 PM

  8. Ryan Bigg
    Ryan Bigg
    • Tag cleared.

    Automatic cleanup of spam.

    October 9th, 2010 @ 10:01 PM