IRB help

11 views
Skip to first unread message

Oliver David

unread,
Jun 21, 2013, 9:17:29 AM6/21/13
to rubyonra...@googlegroups.com
Im new to Ruby and isntalled Rails on Windows 8.  I tried typing this in IRB run it normal or as administrator and getting this result.

might have duplicated this post, first time posting on the group did not see where my post is :)


irb(main):001:0> mkdir lesson2
NameError: undefined local variable or method `lesson2' for main:Object
        from (irb):1
        from C:/RailsInstaller/Ruby1.9.3/bin/irb:12:in `<main>'
irb(main):002:0> cd lesson


Nick van der Wildt

unread,
Jun 21, 2013, 11:11:36 AM6/21/13
to rubyonra...@googlegroups.com
Hi there,

The problem is that you're trying to run a command that's not a part of
Ruby, but just part of the basic command tools Windows provides. When
you type "mkdir lesson2", you're giving the command to create a folder
named "lesson2", however, like I said, this is not part of Ruby and IRB.

Solution is to exit IRB (CTRL+D?) and then putting the command "mkdir
lesson2", after which you can open IRB again to try some Ruby code.

I hope this helps! If you have any other questions, feel free to let me
know :-)

--
Posted via http://www.ruby-forum.com/.

Joel Pearson

unread,
Jun 21, 2013, 12:03:52 PM6/21/13
to rubyonra...@googlegroups.com
You can also execute system commands from within irb using "system"
system( "mkdir lesson2" )
or backticks
`mkdir lesson2`

Although in the case of "mkdir" you'll probably want to use "Dir.pwd" to
check you're in the right directory, and "Dir.chdir('c:/myfolder')" to
move to the correct folder first.
Reply all
Reply to author
Forward
0 new messages