From: Josh Cheek Date: 2013-04-21T11:03:43+09:00 Subject: Re: Running file from command line issue --089e0158c7ce77fbb204dad55ce5 Content-Type: text/plain; charset=ISO-8859-1 When you require a file, it looks through an array of directories (called the $LOAD_PATH) until it finds that file. In older rubies, the current directory (represented with a period) was in the load path, in newer rubies, it was removed. The simple solution to your problem, in IRB, is to run irb like this `irb -I .` (that's a capitol "i") which will add the current working directory back into the load path, like it is on the Lynda.com version. When you get to writing programs that depend on this, you can use require_relative instead of require. When you get to writing real programs, you'll need to learn and understand the load path. When you get that far, read the section about the load path from here http://guides.rubygems.org/patterns/ -Josh On Wed, Apr 17, 2013 at 8:46 PM, Gouverneur Cadwalader wrote: > Hello. This is my first post and I'm new to coding and ruby. I'm > trying to learn the basics right now from Lynda.com. I'm trying to run > the above file "methods.rb" from the command line. In the command prompt > I navigate to the correct folder, switch to irb, and then I use > >require"methods.rb". > > In the lynda tutorial video, this returns >true. It works. > > When I do it, I get > > LoadError: cannot load such file -- methods.rb > from > C:/Ruby200/lob/ruby/2.0/rubygems/core_ext/kernel_require.rb:45:in > 'require' > from > C:/Ruby200/lob/ruby/2.0/rubygems/core_ext/kernel_require.rb:45:in > 'require' > from (irb):2 > from C:/Ruby200/bin/irb:12:in '
' > > This tutorial I'm watching is about four years old, so he's using an > older version of ruby. I know this is probably the simplest thing, but > as a newbie I have zero decoding skill. Any help would be appreciated. > > Lastly, if you know of a better way to start learning ruby than the > lynda tutorail series, I'm very open to input of any kind. > > Thanks in advance, > -S. > > Attachments: > http://www.ruby-forum.com/attachment/8351/methods.rb > > > -- > Posted via http://www.ruby-forum.com/. > > --089e0158c7ce77fbb204dad55ce5 Content-Type: text/html; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable
When you require a file, it looks through an array of dire= ctories (called the $LOAD_PATH) until it finds that file. In older rubies, = the current directory (represented with a period) was in the load path, in = newer rubies, it was removed.

The simple solution to your problem, in IRB, is to run= irb like this `irb -I .` (that's a capitol "i") which will a= dd the current working directory back into the load path, like it is on the= Lynda.com version.

When you get to writing programs that depen= d on this, you can use require_relative instead of require. When you get to= writing real programs, you'll need to learn and understand the load pa= th. When you get that far, read the section about the load path from here <= a href=3D"http://guides.rubygems.org/patterns/">http://guides.rubygems.org/= patterns/

-Josh



On Wed, Apr 17, 20= 13 at 8:46 PM, Gouverneur Cadwalader <lists@ruby-forum.com> wrote:
Hello. This is my first post and I'm new= to coding and ruby. I'm
trying to learn the basics right now from Lynda.com. I'm trying to run<= br> the above file "methods.rb" from the command line. In the command= prompt
I navigate to the correct folder, switch to irb, and then I use
>require"methods.rb".

In the lynda tutorial video, this returns >true. It works.

When I do it, I get

LoadError: cannot load such file -- methods.rb
=A0 =A0from
C:/Ruby200/lob/ruby/2.0/rubygems/core_ext/kernel_require.rb:45:in
'require'
=A0 =A0from
C:/Ruby200/lob/ruby/2.0/rubygems/core_ext/kernel_require.rb:45:in
'require'
=A0 =A0from (irb):2
=A0 =A0from C:/Ruby200/bin/irb:12:in '<main>'

This tutorial I'm watching is about four years old, so he's using a= n
older version of ruby. I know this is probably the simplest thing, but
as a newbie I have zero decoding skill. Any help would be appreciated.

Lastly, if you know of a better way to start learning ruby than the
lynda tutorail series, I'm very open to input of any kind.

Thanks in advance,
-S.

Attachments:
http://www.ruby-forum.com/attachment/8351/methods.rb


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


--089e0158c7ce77fbb204dad55ce5--