Re: Full paths of Ruby interpreter and running script


#1

I appreciate these suggestions, but found that they do not actually
solve my problem. If a full Ruby installation is done with the One
Click Installer, the code does return the folder containing the Ruby
interpreter (C:\Ruby\bin by default). In distributing a Ruby program I
am developing, however, I intend to distribute only the minimum set of
files for running the program. Through trial and error, I have found
that these are ruby.exe, msvcrt-ruby18.dll, and the particular .so or
.rb library files that my main script.rb file calls.

In testing the rbconfig technique, I copied these files, including
rbconfig.rb, into a temporary folder, c:\TestRuby. When I ran a test
program at the command prompt, the correct path was not given. It
should have been C:\TestRuby\rubyw.exe for the interpreter (or
C:\TestRuby\test.rb for the script file).

Windows has an API function, GetModuleFileName , that returns the full
path of the running executable. I may be able to wrap an API call using
the Win32API library, but prefer a native Ruby approach if possible.

Jamal


#2

On Tue, 18 Apr 2006, Jamal M. wrote:

rbconfig.rb, into a temporary folder, c:\TestRuby. When I ran a test
program at the command prompt, the correct path was not given. It
should have been C:\TestRuby\rubyw.exe for the interpreter (or
C:\TestRuby\test.rb for the script file).

Windows has an API function, GetModuleFileName , that returns the full
path of the running executable. I may be able to wrap an API call using
the Win32API library, but prefer a native Ruby approach if possible.

Jamal

check out dl - you can’t make native calls directory. of course you
also have
the win32 api in ruby…

either should give you what you want.

-a