Forum: Ruby Re: Full paths of Ruby interpreter and running script

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.
2cf408af3f08d3575c9cd7697158a8f1?d=identicon&s=25 Jamal Mazrui (Guest)
on 2006-04-17 21:50
(Received via mailing list)
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
Cb48ca5059faf7409a5ab3745a964696?d=identicon&s=25 unknown (Guest)
on 2006-04-17 22:15
(Received via mailing list)
On Tue, 18 Apr 2006, Jamal Mazrui 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
This topic is locked and can not be replied to.