Forum: Ruby How can I load my own files to ruby? (Win XP)

Announcement (2017-05-07): www.ruby-forum.com is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see rubyonrails.org/community and ruby-lang.org/en/community for other Rails- und Ruby-related community platforms.
Stephan.Kassel (Guest)
on 2005-12-01 17:29
(Received via mailing list)
I am just trying to get some knowledge in Ruby. For this I am playing
with some tutorials.

In the tutorial I have to save some code to a file and load it
afterwards in the irb (with require).

I don't want to mess up the installation, so I am saving all files
under my own special directory E:/User/stk/Programming/Ruby.

Which enviroment variable do I have to use? What shall I do?

There are no comments on this in the installation instructions and in
the faq(s) afaik.

Any help is appreciated. (No, I don't want to make a lot of other
installations to get it done.)
   Stephan.

P.S.: I have installed ruby 1.8.2 with the OneClickInstaller on
RubyForge.
rosco (Guest)
on 2005-12-01 17:45
(Received via mailing list)
On Thu, 01 Dec 2005 15:25:00 -0000, removed_email_address@domain.invalid
<removed_email_address@domain.invalid> wrote:

>
(I don't know about Windows, but I expect it's the same in this
regard?).

If you start IRB from that directory, you should be able to require your
file with a simple:

require 'myfile'

assuming your file is named 'myfile.rb'. You can also give full
path/filename to require I think.

Alternatively, a quick and dirty way in IRB is to just do:

$: << 'E:/User/stk/Programming/Ruby'			# ?slashes?

when you first run IRB. From then, your directory will be in the library
search path.

(Aside: Stick with it - IRB will quickly become one of the most valuable
tools you have when learning Ruby :))
blargity (Guest)
on 2005-12-01 18:06
(Received via mailing list)
On Thursday 01 December 2005 09:27, removed_email_address@domain.invalid wrote:
> In the tutorial I have to save some code to a file and load it
> afterwards in the irb (with require).
>
> I don't want to mess up the installation, so I am saving all files
> under my own special directory E:/User/stk/Programming/Ruby.

e:
cd User\stk\Programming\Ruby
irb -r yourfile.rb or irb then requre 'yourfile.rb'

Am I missing something?
bob_showalter (Guest)
on 2005-12-01 18:18
(Received via mailing list)
removed_email_address@domain.invalid wrote:
> I am just trying to get some knowledge in Ruby. For this I am playing
> with some tutorials.
>
> In the tutorial I have to save some code to a file and load it
> afterwards in the irb (with require).
>
> I don't want to mess up the installation, so I am saving all files
> under my own special directory E:/User/stk/Programming/Ruby.
>
> Which enviroment variable do I have to use? What shall I do?

The RUBYLIB environment variable lets you specify additional directories
to be searched by 'require'. irb picks this up. Both ruby and irb (at
least as of 1.8.2) support a -I option too.
Stephan.Kassel (Guest)
on 2005-12-01 21:33
(Received via mailing list)
Thank you.

This was the answer I really needed. Also many thanks to Ross to
provide me with a quick workaround. My problem is solved. (Maybe until
the next time when I need to know something about useful environment
variables  for ruby ;-)

Regards,
    Stephan.
This topic is locked and can not be replied to.