This project is archived and is in readonly mode.

#2901 ✓committed
ronin-9952 (at lighthouseapp)

Increase error message output in boot.rb

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

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.

Comments and changes to this ticket

  • Jeremy Kemper

    Jeremy Kemper May 4th, 2010 @ 06:48 PM

    • Milestone changed from 2.x to 3.x
  • David Trasbo

    David Trasbo June 27th, 2010 @ 01:06 PM

    • 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.

  • José Valim

    José Valim June 27th, 2010 @ 01:28 PM

    • 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.

  • David Trasbo

    David Trasbo June 29th, 2010 @ 10:13 AM

    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.

  • Lenary

    Lenary June 29th, 2010 @ 10:32 AM

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

  • David Trasbo

    David Trasbo June 29th, 2010 @ 10:44 AM

    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.

  • Repository

    Repository June 29th, 2010 @ 04:55 PM

    • 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...

  • Ryan Bigg

    Ryan Bigg October 9th, 2010 @ 10:01 PM

    • Tag cleared.

    Automatic cleanup of spam.

Create your profile

Help contribute to this project by taking a few moments to create your personal profile. Create your profile »

<h2 style="font-size: 14px">Tickets have moved to Github</h2>

The new ticket tracker is available at <a href="https://github.com/rails/rails/issues">https://github.com/rails/rails/issues</a>

Attachments

Referenced by

Pages