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.

On Fri, May 13, 2011 at 11:37 PM, David J. [email protected] 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?

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.


Phillip G.

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.

-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Am 13.05.2011 23:37, schrieb David J.:

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.

require “rbconfig”
puts RbConfig::CONFIG[“bindir”]

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

Vale,
Marvin
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.11 (GNU/Linux)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org/

iQEcBAEBAgAGBQJNzkISAAoJELh1XLHFkqhah7kH/iPcpT2mA5btyERAVskrRtep
7asO2ATkmU0JkkMdeQ6XuNe9O6aNQt5zOYkG2HGzS+0Mga78VnLP74sf7Pn629jH
v7XfDXOXxK97hBPYuYu0be9Ne/hNIfU+MuszAG7/bKgdp2ArM7kg2xs0WSnWq2eW
03arRL4+I9AFOnuFEQiYjA5i2J9Vh7RJoz+q+517rmSo+SrJowAMWhAufZwj7SmW
jumiMB98jvvInyBgVAkfb54QfXNLKUI+UMVWeTEDuW2y72hSMPz6F3si3NFVy6/7
cRFMDbJ7FzsVU6mgZtfbjASThH/NSA9YN0IfcbcXJ+j6lQ9VsJqbrJd8yi2cVr8=
=eBcs
-----END PGP SIGNATURE-----

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

David