How to tell which openssl lib is actually being used by an RVM-installed ruby

孤街浪徒 提交于 2019-11-30 04:13:07

问题


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.


回答1:


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




回答2:


How about:

ruby -ropenssl -e "puts OpenSSL::VERSION"


来源:https://stackoverflow.com/questions/13956134/how-to-tell-which-openssl-lib-is-actually-being-used-by-an-rvm-installed-ruby

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!