# Ruby error messages

**URL:** <https://www.ruby-forum.com/t/ruby-error-messages/48765>\
**Category:** Ruby\
**Created:** [November 24, 2005, 9:02am UTC](https://www.ruby-forum.com/t/ruby-error-messages/48765 "2005-11-24T09:02:10Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![sam](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/s/5f9b8f/32.png) [@sam](https://www.ruby-forum.com/u/sam)\
**Post date:** [November 24, 2005, 9:02am UTC](https://www.ruby-forum.com/t/ruby-error-messages/48765/1 "2005-11-24T09:02:10Z")

</div>

Hi there,

Is the meaning of the ruby error messages defined anywhere? E.g. I get  
something like:

NameError: uninitialized constant Blah

and maybe you’ll tell me it’s self explanatory, but it would be nice to  
look through a list of errors and read more about what they mean. I  
searched the web and asked on ruby-lang irc channel but haven’t turned  
up anything yet.

Many thanks in advance.

CHEERS\> SAM

---

<div class="post-metadata">

**Author:** ![sam](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/s/5f9b8f/32.png) [@sam](https://www.ruby-forum.com/u/sam)\
**Post date:** [November 24, 2005, 9:54am UTC](https://www.ruby-forum.com/t/ruby-error-messages/48765/2 "2005-11-24T09:54:30Z")

</div>

Sam J. wrote:

> up anything yet.  
> As far as I know there is no such comprehensive list (note, I may be  
> wrong  
> here). But closely looking at the exception stack trace and the code it  
> points to you usually see what’s wrong very fast.

Kind regards

```
robert
```

---

<div class="post-metadata">

**Author:** ![sam](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/s/5f9b8f/32.png) [@sam](https://www.ruby-forum.com/u/sam)\
**Post date:** [November 24, 2005, 11:51am UTC](https://www.ruby-forum.com/t/ruby-error-messages/48765/3 "2005-11-24T11:51:29Z")

</div>

> NameError: uninitialized constant Blah

irb(main):002:0\> x = My\_case\_is\_wrong  
NameError: uninitialized constant My\_case\_is\_wrong  
from (irb):2  
irb(main):003:0\>

usually,  
grep -r Blah you\_program\_dir  
is make clear the situation.

---

<div class="post-metadata">

**Author:** ![sam](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/s/5f9b8f/32.png) [@sam](https://www.ruby-forum.com/u/sam)\
**Post date:** [November 24, 2005, 12:39pm UTC](https://www.ruby-forum.com/t/ruby-error-messages/48765/4 "2005-11-24T12:39:54Z")

</div>

On Nov 24, 2005, at 8:01, Sam J. wrote:

> searched the web and asked on ruby-lang irc channel but haven’t turned  
> up anything yet.

Sounds like a decent wiki page.

What it means is that something Ruby considers a constant is being  
used without being initialised, which I suppose is obvious.

The less-obvious bit is “something Ruby considers a constant” which  
is “an identifier that starts with an uppercase letter”. All class  
and module names, for instance. (Forgive me if that’s a little  
amorphous - I don’t have a language grammar to poke through for the  
actual definition).

So, for this error, I would look for typos, particularly in  
assignment statements (as one poster mentioned), but also in class  
definitions - maybe you defined your class as “Balh” when you meant  
“Blah”. For particularly tricky cases, you can get a list of  
constants via ‘Module.constants’.

matthew smillie.

---

<div class="post-metadata">

**Author:** ![sam](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/s/5f9b8f/32.png) [@sam](https://www.ruby-forum.com/u/sam)\
**Post date:** [November 24, 2005, 1:41pm UTC](https://www.ruby-forum.com/t/ruby-error-messages/48765/5 "2005-11-24T13:41:13Z")

</div>

Find Gruff lib. There is a base.rb file.

In  
-------------8\<-------8\<-------------

1. begin
2. require ‘rmagick’
3. rescue LoadError
4. require ‘RMagick’ # capitalized on Windows
5. end

-------------8\<-------8\<-------------  
comment out lines 1-3 and 5. Gruff does not deal good with “requre” on  
Win.

Hope this helps you.

Pavel

---

<div class="post-metadata">

**Author:** ![sam](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/s/5f9b8f/32.png) [@sam](https://www.ruby-forum.com/u/sam)\
**Post date:** [November 24, 2005, 1:08pm UTC](https://www.ruby-forum.com/t/ruby-error-messages/48765/6 "2005-11-24T13:08:08Z")

</div>

Thanks Robert and Yuri,

As a ruby newbie I’m finding that I’m getting a little stuck. I’ve been  
programming in Java/C like languages for about 15 years, so maybe I’m  
just having trouble getting used to the brave new world, so perhaps  
you’ll bear with me while I take you through some details.

I really like ruby but I’m finding it hard to get to the bottom of  
things when I do get errors.

My current situation involves a module called Gruff. I’ve mailed my  
problems to the gruff forums on rubyforge, and we’re working on it  
there, however I’d really like to be able to help solve the problem  
myself.

I’ve downloaded gruff and rmagick using gems, and I’m trying a gruff  
code sample in irb (I previously tried an rmagick sample and that  
works):

require ‘rubygems’  
require ‘gruff’

g = Gruff::Line.new

require ‘rubygems’ returns a fail, and require ‘gruff’ gives an error,  
but I can get it to just return false if I comment out the relevant line  
of code in the gruff source.

Anyhow, when I type g = Gruff::Line.new I get the this error:

NameError: uninitialized constant Gruff

which I presume is telling me that we have failed to pull in the gruff  
module - adjusting the capitalization is no help:

irb(main):004:0\> g = gruff::Line.new  
NameError: undefined local variable or method `gruff’ for  
#Object:0x2959258  
from (irb):4

The thing is I’m stuck as to how to proceed from here - is there some  
way for me to interogate the system so I can find out why the require  
‘gruff’ is failing?

As I understand it my path is set up fine:

irb(main):005:0\> $:  
=\> [“d:/ruby/lib/ruby/gems/1.8/gems/RMagick-win32-1.9.2-mswin32/bin”,  
“d:/ruby/lib/ruby/ge  
ms/1.8/gems/RMagick-win32-1.9.2-mswin32/lib”,  
“d:/ruby/lib/ruby/gems/1.8/gems/gruff-0.0.6/  
bin”, “d:/ruby/lib/ruby/gems/1.8/gems/gruff-0.0.6/lib”,  
“d:/ruby/lib/ruby/site\_ruby/1.8”,  
“d:/ruby/lib/ruby/site\_ruby/1.8/i386-msvcrt”,  
“d:/ruby/lib/ruby/site\_ruby”, “d:/ruby/lib/r  
uby/1.8”, “d:/ruby/lib/ruby/1.8/i386-mswin32”, “.”]

i.e. i get all the above after entering the require commands, despite  
the fact that they return failures.

hmm, so actually writing all this out helped - as I just fixed the  
problem. It seems that I needed to restart irb each time I made  
modifications to the source code in order to see the continuing errors  
being generated after my modifications.

I was confused beacause after throwing an error once, a repeat call to  
require would just return false, without any error message. By  
restarting irb and seeing the addtional errors, I commented out a load  
of undef\_method calls in rmagick.rb and now it all works.

Sometimes you just need to be able to explain these things to someone  
🙂

Many thanks for your input

CHEERS\> SAM

Robert K. wrote:

> As far as I know there is no such comprehensive list (note, I may be wrong  
> here). But closely looking at the exception stack trace and the code it  
> points to you usually see what’s wrong very fast.
