Welcome to the Treehouse Community

Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.

Start your free trial

Ruby Ruby Foundations Ruby Basics IRB and Your First Ruby Program

Ruby error: undefined local variable

I'm receiving this message from terminal:

$ ruby hello.rb hello.rb:1:in <main>': undefined local variable or methodworldโ€' for main:Object (NameError)

I have textmate setup properly with shell scripting support installed. I'm wondering if the clash is with RVM and RBENV. I recall reading somewhere in the RBENV doc that having RVM would disrupt it. Any ideas? Thanks in advance!

Can you show the code that you are trying to run?

Robert, do you know how you fixed this? I am getting the same message.

2 Answers

$ruby hello.rb

It is the basic puts "Hello World" program.

Error message:

hello.rb:1:in <main>': undefined local variable or methodworldโ€' for main:Object (NameError)

Does running the same line in irb work?

$ irb
> puts "Hello World"

yes it does.

I'm not sure what happened, but everything is now working.