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![](https://ecs-static.teamtreehouse.com/assets/views/marketing/shared/community-banner-white-47072046c51352fe6a69f5e691ff5700b28bb11d45197d7bdf066d9ea3f72d0c.webp)
![Anders Lund](https://secure.gravatar.com/avatar/7ca43e64daabe4f11bf4228f24eaf319?s=96&d=https%3A%2F%2Fecs-static.teamtreehouse.com%2Fassets%2Fcontent%2Fdefault_avatar-445fbbabfc8dc9188fb5967fe43322ee0c3e0dd1e10f378bf8343784af5a13eb.webp&r=pg)
Anders Lund
3,061 PointsRun Ruby program in ComandLine
I try to run Ruby program in commandLine, and I always get the "`require': cannot load such file -- 00_hello (LoadError)"
Does anyone know how to fix this?
Thanks
![Anders Lund](https://secure.gravatar.com/avatar/7ca43e64daabe4f11bf4228f24eaf319?s=60&d=https%3A%2F%2Fecs-static.teamtreehouse.com%2Fassets%2Fcontent%2Fdefault_avatar-445fbbabfc8dc9188fb5967fe43322ee0c3e0dd1e10f378bf8343784af5a13eb.webp&r=pg)
Anders Lund
3,061 PointsThis is the code: it supposed to fail they say, and give an error about the "hello" function, but I get a different error...
require "00_hello"
describe "the hello function" do it "says hello" do hello.should == "Hello!" end end
describe "the greet function" do it "says hello to someone" do greet("Alice").should == "Hello, Alice!" end
it "says hello to someone else" do greet("Bob").should == "Hello, Bob!" end end
![Maciej Czuchnowski](https://uploads.teamtreehouse.com/production/profile-photos/103489/micro_IMG_3403.jpg)
Maciej Czuchnowski
36,441 PointsOK, what tutorial is it? Can you link it?
![Anders Lund](https://secure.gravatar.com/avatar/7ca43e64daabe4f11bf4228f24eaf319?s=60&d=https%3A%2F%2Fecs-static.teamtreehouse.com%2Fassets%2Fcontent%2Fdefault_avatar-445fbbabfc8dc9188fb5967fe43322ee0c3e0dd1e10f378bf8343784af5a13eb.webp&r=pg)
Anders Lund
3,061 Pointsits not a tutorial, but more like a lesson I got
# Hello!
This lab teaches basic Ruby function syntax.
## Run the test
bundle exec rspec spec/00_hello_spec.rb
## Watch it fail
You should see an error. Don't get scared! Try to read it and
figure out what the computer wants to tell you. Somewhere on the
first line it should say something like
the hello function
says hello (FAILED - 1)
Failures:
1) the hello function says hello
Failure/Error: hello.should == "Hello!"
NameError:
undefined local variable or method `hello' for #<RSpec::Core::ExampleGroup::Nested_1:0x000001009b8808>
# ./hello/hello_spec.rb:5:in `block (2 levels) in <top (required)>'
## Create the hello function
Fix this by opening lib/00_hello.rb
and creating an empty function:
def hello
end
Save it. Run the test again.
## Watch it fail
Now you should see an error like this:
the hello function
says hello (FAILED - 1)
Failures:
1) the hello function says hello
Failure/Error: hello().should == "Hello!"
expected: "Hello!"
got: nil (using ==)
# ./hello/hello_spec.rb:5:in `block (2 levels) in <top (required)>'
This means that while it found the file, and it found the function,
it's not returning anything! ("nil" is the Ruby way of saying "not
anything".)
## Make it return something
Inside the "hello" function, put a single line containing a string
that is not "Hello!". (Here we are simulating you making an honest
mistake, so we can see what the error message looks like.)
def hello
"whuh?"
end
Save it. Run the test again.
## Watch it fail
Now you should see an error like this:
1) the hello function says hello
Failure/Error: hello().should == "Hello!"
expected: "Hello!"
got: "whuh?" (using ==)
# ./hello/hello_spec.rb:5:in `block (2 levels) in <top (required)>'
Correct this by changing "whuh?" to "Hello!". Save it. Run the test again.
## Watch it pass!
Hooray! Finally! It works!
## Give yourself a high five
Also, sing a song and do a little dance.
## And then...
Fix the next failure! :-)
the hello function
says hello
the greet function
says hello to someone (FAILED - 1)
In order to get the next test to pass, your function will need to
accept an argument.
def greet(who)
"Hello, #{who}!"
end
require "00_hello"
describe "the hello function" do it "says hello" do hello.should == "Hello!" end end
describe "the greet function" do it "says hello to someone" do greet("Alice").should == "Hello, Alice!" end
it "says hello to someone else" do greet("Bob").should == "Hello, Bob!" end end
![Maciej Czuchnowski](https://uploads.teamtreehouse.com/production/profile-photos/103489/micro_IMG_3403.jpg)
Maciej Czuchnowski
36,441 PointsSo do you have the file lib/00_hello.rb
? It should be a 00_hello.rb
file in the folder called lib
.
![Anders Lund](https://secure.gravatar.com/avatar/7ca43e64daabe4f11bf4228f24eaf319?s=60&d=https%3A%2F%2Fecs-static.teamtreehouse.com%2Fassets%2Fcontent%2Fdefault_avatar-445fbbabfc8dc9188fb5967fe43322ee0c3e0dd1e10f378bf8343784af5a13eb.webp&r=pg)
Anders Lund
3,061 Pointsyes i do have that file
![Maciej Czuchnowski](https://uploads.teamtreehouse.com/production/profile-photos/103489/micro_IMG_3403.jpg)
Maciej Czuchnowski
36,441 PointsOK, try changing this:
require "00_hello"
into this:
require "lib/00_hello"
![Anders Lund](https://secure.gravatar.com/avatar/7ca43e64daabe4f11bf4228f24eaf319?s=60&d=https%3A%2F%2Fecs-static.teamtreehouse.com%2Fassets%2Fcontent%2Fdefault_avatar-445fbbabfc8dc9188fb5967fe43322ee0c3e0dd1e10f378bf8343784af5a13eb.webp&r=pg)
Anders Lund
3,061 PointsI ganged it and got the same
ruby /Users/anderslund/Downloads/test-first-ruby-master/spec/00_hello_spec.rb
/Users/anderslund/.rvm/rubies/ruby-2.1.2/lib/ruby/site_ruby/2.1.0/rubygems/core_ext/kernel_require.rb:54:in require': cannot load such file -- lib/00_hello (LoadError)
from /Users/anderslund/.rvm/rubies/ruby-2.1.2/lib/ruby/site_ruby/2.1.0/rubygems/core_ext/kernel_require.rb:54:in
require'
from /Users/anderslund/Downloads/test-first-ruby-master/spec/00_hello_spec.rb:103:in `<main>'
Anderss-MacBook-Pro:Desktop anderslund$
![Gloria Dwomoh](https://uploads.teamtreehouse.com/production/profile-photos/1669872/micro_287e5c5fa5fa84a62083d156a02582e2.jpg)
Gloria Dwomoh
13,116 PointsCan you try changing it to require_relative "00_hello"?
![Anders Lund](https://secure.gravatar.com/avatar/7ca43e64daabe4f11bf4228f24eaf319?s=60&d=https%3A%2F%2Fecs-static.teamtreehouse.com%2Fassets%2Fcontent%2Fdefault_avatar-445fbbabfc8dc9188fb5967fe43322ee0c3e0dd1e10f378bf8343784af5a13eb.webp&r=pg)
Anders Lund
3,061 Pointstried that too, did not work
![Anders Lund](https://secure.gravatar.com/avatar/7ca43e64daabe4f11bf4228f24eaf319?s=60&d=https%3A%2F%2Fecs-static.teamtreehouse.com%2Fassets%2Fcontent%2Fdefault_avatar-445fbbabfc8dc9188fb5967fe43322ee0c3e0dd1e10f378bf8343784af5a13eb.webp&r=pg)
Anders Lund
3,061 PointsGloria, thanks I got it to work through the website :) but I have another question about the Ruby syntax, why do the write "describe" and "it"? I've gone through so many tutorials and read a lot about Ruby but haven't seen those words yet, u know what they mean in the Ruby syntax? thanks
![Gloria Dwomoh](https://uploads.teamtreehouse.com/production/profile-photos/1669872/micro_287e5c5fa5fa84a62083d156a02582e2.jpg)
Gloria Dwomoh
13,116 PointsHi Anders, I am glad you got it to work. It is not actual "ruby syntax". That is why you don't see it there. It is something that has to do with RSpec which is a ruby testing tool. You can read more about it here Basic structure (describe
/it
) and also have a look at this to learn more on what Rspec is. :)
![Anders Lund](https://secure.gravatar.com/avatar/7ca43e64daabe4f11bf4228f24eaf319?s=60&d=https%3A%2F%2Fecs-static.teamtreehouse.com%2Fassets%2Fcontent%2Fdefault_avatar-445fbbabfc8dc9188fb5967fe43322ee0c3e0dd1e10f378bf8343784af5a13eb.webp&r=pg)
Anders Lund
3,061 PointsThanks you so much for all your help Gloria, really, really awesome!
![Gloria Dwomoh](https://uploads.teamtreehouse.com/production/profile-photos/1669872/micro_287e5c5fa5fa84a62083d156a02582e2.jpg)
Gloria Dwomoh
13,116 PointsYou are welcome :D
5 Answers
![Unsubscribed User](https://secure.gravatar.com/avatar/74c140b954cdf25bc43882757f7499fa?s=96&d=https%3A%2F%2Fecs-static.teamtreehouse.com%2Fassets%2Fcontent%2Fdefault_avatar-445fbbabfc8dc9188fb5967fe43322ee0c3e0dd1e10f378bf8343784af5a13eb.webp&r=pg)
Unsubscribed User
6,144 PointsHello,
What is the name of your file ? If your file is called 'hello.rb', you should run this command :
ruby hello.rb
![Gloria Dwomoh](https://uploads.teamtreehouse.com/production/profile-photos/1669872/micro_287e5c5fa5fa84a62083d156a02582e2.jpg)
Gloria Dwomoh
13,116 PointsWhat exactly do you type before this error appears?
![Anders Lund](https://secure.gravatar.com/avatar/7ca43e64daabe4f11bf4228f24eaf319?s=96&d=https%3A%2F%2Fecs-static.teamtreehouse.com%2Fassets%2Fcontent%2Fdefault_avatar-445fbbabfc8dc9188fb5967fe43322ee0c3e0dd1e10f378bf8343784af5a13eb.webp&r=pg)
Anders Lund
3,061 Pointsit's called 00_hello_spec.rb
It's a challenge from a tutorial, and when he runs it it says something else in the command line like, can't read the file and so on. Cus I have tried the ruby 00_hello_spec.rb but it gave me the same feedback
![Gloria Dwomoh](https://uploads.teamtreehouse.com/production/profile-photos/1669872/micro_287e5c5fa5fa84a62083d156a02582e2.jpg)
Gloria Dwomoh
13,116 PointsWhich tutorial is it? Can you explain the process of what you did? What is in 00_hello_spec.rb ?
![Anders Lund](https://secure.gravatar.com/avatar/7ca43e64daabe4f11bf4228f24eaf319?s=60&d=https%3A%2F%2Fecs-static.teamtreehouse.com%2Fassets%2Fcontent%2Fdefault_avatar-445fbbabfc8dc9188fb5967fe43322ee0c3e0dd1e10f378bf8343784af5a13eb.webp&r=pg)
Anders Lund
3,061 PointsIt's from a school (kind of) I got the file from them (00_hello_spec.rb) In that file it says "Run the file and watch it fail, the error should say something like": 1) the hello function says hello
Failure/Error: hello.should == "Hello!"
NameError:
undefined local variable or method `hello' for #<RSpec::Core::ExampleGroup::Nested_1:0x000001009b8808>
# ./hello/hello_spec.rb:5:in `block (2 levels) in <top (required)>'
Then when I run the file I type: ruby (and then drag the file in) /Users/anderslund/Downloads/test-first-ruby-master/spec/00_hello_spec.rb
And I get the cannot read the file... Error and all that.
![Anders Lund](https://secure.gravatar.com/avatar/7ca43e64daabe4f11bf4228f24eaf319?s=96&d=https%3A%2F%2Fecs-static.teamtreehouse.com%2Fassets%2Fcontent%2Fdefault_avatar-445fbbabfc8dc9188fb5967fe43322ee0c3e0dd1e10f378bf8343784af5a13eb.webp&r=pg)
Anders Lund
3,061 PointsGloria: I type: ruby /Users/anderslund/Downloads/test-first-ruby-master/spec/00_hello_spec.rb
![Gloria Dwomoh](https://uploads.teamtreehouse.com/production/profile-photos/1669872/micro_287e5c5fa5fa84a62083d156a02582e2.jpg)
Gloria Dwomoh
13,116 PointsI see. Have you tried doing... cd [dir] till you reach the spec folder and then run the "ruby 00_hello_spec.rb" instead of that path?
![Anders Lund](https://secure.gravatar.com/avatar/7ca43e64daabe4f11bf4228f24eaf319?s=60&d=https%3A%2F%2Fecs-static.teamtreehouse.com%2Fassets%2Fcontent%2Fdefault_avatar-445fbbabfc8dc9188fb5967fe43322ee0c3e0dd1e10f378bf8343784af5a13eb.webp&r=pg)
Anders Lund
3,061 PointsYeah it gives me the same error, cannot load such file. The reason I get the error is not the problem, the problem is that I get the wrong error, cus the program is supposed to fail
![Gloria Dwomoh](https://uploads.teamtreehouse.com/production/profile-photos/1669872/micro_287e5c5fa5fa84a62083d156a02582e2.jpg)
Gloria Dwomoh
13,116 PointsCan you try uploading it to your workspace and see if it gives you the same error there?
![Anders Lund](https://secure.gravatar.com/avatar/7ca43e64daabe4f11bf4228f24eaf319?s=60&d=https%3A%2F%2Fecs-static.teamtreehouse.com%2Fassets%2Fcontent%2Fdefault_avatar-445fbbabfc8dc9188fb5967fe43322ee0c3e0dd1e10f378bf8343784af5a13eb.webp&r=pg)
Anders Lund
3,061 PointsI'm kind of new to this. what do u mean "uploading it to your workspace" :P
![Gloria Dwomoh](https://uploads.teamtreehouse.com/production/profile-photos/1669872/micro_287e5c5fa5fa84a62083d156a02582e2.jpg)
Gloria Dwomoh
13,116 PointsOn the panel on the right...where it says... "Home", "Tracks" ... there is something called.. "Workspaces". If you go there you can click "New" and then give it a title ex. "Homework" , an environment "Ruby" ...and in the last option select "Ruby Workspace" that will create a ruby enviroment for you and open a new window with the workspace if you select it. The on the left you will see a folder called "Homework" ... you right click and select "upload file". Then upload your ruby file and run it with ruby 00_hello_spec.rb and see if it runs as expected. If it gives you the same error with the one you have listed to us then it is a problem with the file.
![Anders Lund](https://secure.gravatar.com/avatar/7ca43e64daabe4f11bf4228f24eaf319?s=60&d=https%3A%2F%2Fecs-static.teamtreehouse.com%2Fassets%2Fcontent%2Fdefault_avatar-445fbbabfc8dc9188fb5967fe43322ee0c3e0dd1e10f378bf8343784af5a13eb.webp&r=pg)
Anders Lund
3,061 Pointsokey, I have uploaded the file in Workspaces, and should i run it in workspaces (how do I do that) or should I run it in the command line? Thanks
![Gloria Dwomoh](https://uploads.teamtreehouse.com/production/profile-photos/1669872/micro_287e5c5fa5fa84a62083d156a02582e2.jpg)
Gloria Dwomoh
13,116 PointsThere is something called "console" in the workspace. When you are on the workspace you created you will see it. There is an editor above and a console below. You run it in the console.
![Anders Lund](https://secure.gravatar.com/avatar/7ca43e64daabe4f11bf4228f24eaf319?s=96&d=https%3A%2F%2Fecs-static.teamtreehouse.com%2Fassets%2Fcontent%2Fdefault_avatar-445fbbabfc8dc9188fb5967fe43322ee0c3e0dd1e10f378bf8343784af5a13eb.webp&r=pg)
Anders Lund
3,061 Pointsin the console I don't get anything but /workspace$
I think it's because i don't call the method or anything, since the program is supposed to fail
![Gloria Dwomoh](https://uploads.teamtreehouse.com/production/profile-photos/1669872/micro_287e5c5fa5fa84a62083d156a02582e2.jpg)
Gloria Dwomoh
13,116 PointsYou have to type what I told you... ruby 00_hello.... to see anything on it. Like you'll normally do on your command line.
![Anders Lund](https://secure.gravatar.com/avatar/7ca43e64daabe4f11bf4228f24eaf319?s=60&d=https%3A%2F%2Fecs-static.teamtreehouse.com%2Fassets%2Fcontent%2Fdefault_avatar-445fbbabfc8dc9188fb5967fe43322ee0c3e0dd1e10f378bf8343784af5a13eb.webp&r=pg)
Anders Lund
3,061 Pointsyes I got the same error... :P
![Gloria Dwomoh](https://uploads.teamtreehouse.com/production/profile-photos/1669872/micro_287e5c5fa5fa84a62083d156a02582e2.jpg)
Gloria Dwomoh
13,116 PointsIf you got the same error then it must be an error in the code. XD
Maciej Czuchnowski
36,441 PointsMaciej Czuchnowski
36,441 PointsCould you show us the code from that file? It seems that something is wrong inside.