Find Ruby /bin/ location

Today's my last day at work, and my boss wants me to move a Ruby library I
wrote to her Windows computer.

I want to create an install script that moves my library into the Ruby bin
directory. One problem: how do I find that directory programmatically? On
Linux I'd shell out to `which`, but that doesn't appear to be an option in
XP.

Thoughts?

David

PS Yes, I've looked into RubyScript2exe (doesn't work with 1.9) and OCRA
(doesn't let the console screen stay open), and I think that using a custom
installer is the way to go here.

The RubyInstaller stores its install location in:
- "HKEY_CURRENT_USER\Software\RubyInstaller\MRI\1.9.2\InstallLocation"
when installed by a user.
- "HKEY_LOCAL_MACHINE\Software\RubyInstaller\MRI\1.9.2\InstallLocation"
when installed for all users by an Administrator.

Alternatively, you can check Ruby's ENV['PATH'] for the Ruby location.
That assumes that Ruby's location is added to the user's or computer's
path, however, which isn't a given.

···

On Fri, May 13, 2011 at 11:37 PM, David Jacobs <developer@wit.io> wrote:

Today's my last day at work, and my boss wants me to move a Ruby library I
wrote to her Windows computer.

I want to create an install script that moves my library into the Ruby bin
directory. One problem: how do I find that directory programmatically? On
Linux I'd shell out to `which`, but that doesn't appear to be an option in
XP.

Thoughts?

--
Phillip Gawlowski

Though the folk I have met,
(Ah, how soon!) they forget
When I've moved on to some other place,
There may be one or two,
When I've played and passed through,
Who'll remember my song or my face.

require "rbconfig"
puts RbConfig::CONFIG["bindir"]

RbConfig is in the stdlib, so you don't have to install something.

Vale,
Marvin

···

Am 13.05.2011 23:37, schrieb David Jacobs:

I want to create an install script that moves my library into the Ruby bin
directory. One problem: how do I find that directory programmatically? On
Linux I'd shell out to `which`, but that doesn't appear to be an option in
XP.

That's exactly what I was looking for. Thanks to both of you.

David

···

require "rbconfig"
puts RbConfig::CONFIG["bindir"]

RbConfig is in the stdlib, so you don't have to install something.