8

I discovered that I can successfully install ruby with any of the following commands:

$ rvm reinstall 1.9.3-p327
$ rvm reinstall 1.9.3-p327 --with-openssl-dir=/usr/local
$ rvm reinstall 1.9.3-p327 --with-openssl-dir=/afdlkjasd_not_a_dir
$ rvm reinstall 1.9.3-p327 --with-openssl-dirffadsf=/afdlkjasd_not_a_dir

Regardless of which of the above commands I used, I can then type:

$ rvm use 1.9.3-p327
Using /home/clay/rvm/gems/ruby-1.9.3-p327
$ which ruby
/home/clay/.rvm/rubies/ruby-1.9.3-p327/bin/ruby
$ ruby -e "puts require('openssl')"
true

I appear to have ssl support regardless of what I do. I guess rvm or the ruby build process don't mind invalid options or values. I have no idea if the --with-openssl-dir option was respected even when I type it (apparently) correctly.

Is rvm linking my ruby with the openssl lib that I intended (the one in /usr/local)? How do I tell which openssl lib a ruby was compiled/linked with?

I'm using Linux Mint 13.

antinome
  • 3,408
  • 28
  • 26

2 Answers2

7

How about:

ruby -ropenssl -e "puts OpenSSL::VERSION"
hdgarrood
  • 2,141
  • 16
  • 23
  • Knowing the version helps partly (it says 1.1.0), so thank you and +1, but I can't accept the answer because it's still not enough to help me figure out which library it is linking against. I have many different files on my system whose names begin with openssl.so or libssl.so and I don't know which one is being linked. None of them have "1.1.0" in the file name. – antinome Dec 19 '12 at 17:41
  • (Or is it even using a shared library? Maybe it's compiled statically, I don't know.) – antinome Dec 19 '12 at 18:19
5

Ruby has quite complicated mechanisms for detecting libraries, every extension has it's own code for that. Fortunately most of the extensions support pkg-config so it's possible to force location of *.pc files:

PKG_CONFIG_PATH=/path/to/openssl/lib/pkgconfig rvm reinstall 1.9.3
rvm use 1.9.3

then after compilation you can verify on OSX:

find $MY_RUBY_HOME -name openssl.bundle | xargs otool -L

or on linux:

find $MY_RUBY_HOME -name openssl.so | xargs ldd

as for the --with-openssl-dir=... it is not fully supported by ruby, it should be --with-opt-dir=... + --with-openssl, opt-dir supports multiple paths separated with : starting from ruby 1.9.3-p327

mpapis
  • 52,729
  • 14
  • 121
  • 158
  • Thank you so much, this gets me much further, although I am still confused. The output after running those two commands on my linux box shows it is linking to ~/.rvm/usr/lib/libssl.so.1.0.0 whereas I had set the PKG_CONFIG_PATH to /usr/lib/x86_64-linux-gnu/pkgconfig. (Or is that expected?) – antinome Dec 19 '12 at 20:08
  • Out of curiosity, what is the ruby executable's relationship to openssl.so? – antinome Dec 19 '12 at 20:13
  • is there `/usr/lib/x86_64-linux-gnu/pkgconfig/libssl.pc` ? also you might need to specify additional `--with-opt-dir=/usr` hopefully ruby can detect it properly - although there might be problems of this because of how 64 bit platforms are handled. – mpapis Dec 19 '12 at 20:15
  • as for the relationship - `openssl.so` is part of an extension and when you do `require 'openssl'` it will be automatically loaded. – mpapis Dec 19 '12 at 20:16
  • I am definitely still missing some pieces in my understanding of what's going on, but I suppose I should channel my confusion into some additional questions on SO rather than ask you to explain the entire ruby build process to me here :-) – antinome Dec 19 '12 at 20:17
  • if you need more help talk to me(`mpapis`) here: http://webchat.freenode.net/?channels=rvm – mpapis Dec 19 '12 at 20:20
  • The `libssl.pc` file exists. I reinstalled with `--with-opt-dir=/usr` but it still says it's linking to the same ssl lib as before – antinome Dec 19 '12 at 20:32
  • 1
    you could `rm -rf $rvm_path/usr` - rvm would reinstall `libyaml` but use the system openssl (if it's possible) – mpapis Dec 19 '12 at 20:56
  • Thanks mpapis, that works and is valuable to know. Deserves more upvotes than I can give. So would this mean it's not currently possible to have one rvm-installed ruby that uses the system openssl and another that uses the openssl in ~/.rvm/usr? – antinome Dec 19 '12 at 21:17
  • it might be not possible with current code in RVM1 and Ruby, RVM2 should make it a lot simpler / possible – mpapis Dec 19 '12 at 22:03