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
Kristina Nelson
4,196 PointsWhy my simple program won't run?
Hi. I just started exploring Ruby. I wanted to run a simple program.
I saved a file in textmate named "hello.rb". I saved it on my desktop and then tried to run it in my terminal. (It was not in irb mode.)
Kristina-Nelsons-MacBook:~ kristinanelson$ ruby hello.rb ruby: No such file or directory -- hello.rb (LoadError) Kristina-Nelsons-MacBook:~ kristinanelson$
The above is what it gave me. What am I missing so it will work?
Thanks,
Kristina
2 Answers
Kevin Granger
20,332 Pointsyou must execute your code in the right directory or give the path for your *.rb
Kevin Granger
20,332 Pointstry this in your command line window :)
cd Desktop
ruby hello.rb
Kristina Nelson
4,196 PointsYeah! It worked!
Thanks.
One last question: how do I know what code to put in the terminal so I can always figure out the path to my rb file? K
Kevin Granger
20,332 Pointslocate hello.rb
Kevin Granger
20,332 PointsYou should bookmark this http://osxdaily.com/2007/02/07/basic-command-line-utilities-tips-commands/
Kristina Nelson
4,196 PointsMany thanks!
Kristina
Kristina Nelson
4,196 PointsKristina Nelson
4,196 PointsHow do I do that? Do you have an example?
K