RUBYLIB on Windows

A

aurelianito

Hi all,
I'm using the excelent ruby one click installer's ruby on windows, but
I'm unable to add a folder to the path that ruby uses to fetch the
scripts.

I have a script named arf_cmp.rb in C:\devel\scripts\test_scripts. So
I've set RUBYLIB=C:\devel\scripts\test_scripts (environment variable).
But when I run: "ruby arf_cmp.rb" the error "ruby: No such file or
directory -- arf_cmp.rb (LoadError)" is shown. If I run the script
using the full path "ruby C:\devel\scripts\test_scripts\arf_cmp.rb" it
runs flawlessly.

I've tried to set the following variables:
RUBYLIB
RUBY_LIB
RUBY_PATH
LOAD_PATH

How can I do to run the script without hardcoding the entire path?

Thank's in advance,
Aureliano.
 
S

Stefan Lang

Hi all,
I'm using the excelent ruby one click installer's ruby on windows,
but I'm unable to add a folder to the path that ruby uses to fetch
the scripts.

I have a script named arf_cmp.rb in C:\devel\scripts\test_scripts.
So I've set RUBYLIB=C:\devel\scripts\test_scripts (environment
variable). But when I run: "ruby arf_cmp.rb" the error "ruby: No
such file or directory -- arf_cmp.rb (LoadError)" is shown. If I
run the script using the full path "ruby
C:\devel\scripts\test_scripts\arf_cmp.rb" it runs flawlessly.

I've tried to set the following variables:
RUBYLIB
RUBY_LIB
RUBY_PATH
LOAD_PATH

How can I do to run the script without hardcoding the entire path?

Put your script in Ruby's bindir. This command:
ruby -r rbconfig -e "puts Config::CONFIG['bindir']"
will print it, on Windows something like "C:\ruby\bin".

The OneClick Installer usually sets up the file extension
association *.rb => Ruby interpreter, thus you should be
able to run your script by typing its name with the .rb extension,
like:
arf_cmp.rb

And if that doesn't work, try:
ruby -S arf_cmp.rb

How does it work:
When you install Ruby with the OneClick Installer, it permanently
adds Ruby's bindir to the Path environment variable with the help
of the registry. Whenever you start a program (not only a ruby
script) from the console, the console will look for the program
file in the directories listed in the Path environment variable
and start the first it can find.

HTH,
Stefan
 
A

Austin Ziegler

Hi all,
I'm using the excelent ruby one click installer's ruby on windows, but
I'm unable to add a folder to the path that ruby uses to fetch the
scripts.

RUBYLIB is only for require, not for programs.

-austin
 
N

nobu.nokada

Hi,

At Sat, 5 Nov 2005 00:50:03 +0900,
Stefan Lang wrote in [ruby-talk:164172]:
And if that doesn't work, try:
ruby -S arf_cmp.rb

And -S let ruby to search RUBYPATH directories.
 
A

aurelianito

Thank you very much, the third option worked like a charm (ruby -S
arf_cmp.rb).

Aureliano.


Stefan said:
Hi all,
I'm using the excelent ruby one click installer's ruby on windows,
but I'm unable to add a folder to the path that ruby uses to fetch
the scripts.

I have a script named arf_cmp.rb in C:\devel\scripts\test_scripts.
So I've set RUBYLIB=C:\devel\scripts\test_scripts (environment
variable). But when I run: "ruby arf_cmp.rb" the error "ruby: No
such file or directory -- arf_cmp.rb (LoadError)" is shown. If I
run the script using the full path "ruby
C:\devel\scripts\test_scripts\arf_cmp.rb" it runs flawlessly.

I've tried to set the following variables:
RUBYLIB
RUBY_LIB
RUBY_PATH
LOAD_PATH

How can I do to run the script without hardcoding the entire path?

Put your script in Ruby's bindir. This command:
ruby -r rbconfig -e "puts Config::CONFIG['bindir']"
will print it, on Windows something like "C:\ruby\bin".

The OneClick Installer usually sets up the file extension
association *.rb => Ruby interpreter, thus you should be
able to run your script by typing its name with the .rb extension,
like:
arf_cmp.rb

And if that doesn't work, try:
ruby -S arf_cmp.rb

How does it work:
When you install Ruby with the OneClick Installer, it permanently
adds Ruby's bindir to the Path environment variable with the help
of the registry. Whenever you start a program (not only a ruby
script) from the console, the console will look for the program
file in the directories listed in the Path environment variable
and start the first it can find.

HTH,
Stefan
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,744
Messages
2,569,483
Members
44,903
Latest member
orderPeak8CBDGummies

Latest Threads

Top