I'm getting the following error:
/Users/user_name/.rbenv/versions/1.8.7-p375/lib/ruby/1.8/net/https.rb:124:in `use_ssl=': uninitialized constant Net::HTTP::OpenSSL (NameError)
So, I opened up the https file and changed one thing just to see what would happen, I did this:
@ssl_context = ::OpenSSL::SSL::SSLContext.new
If you can't see it, I added ::
to OpenSSL::SSL::SSLContext.new
in the method:
def use_ssl=(flag)
and the problem went away.
Now obviously I can't edit the source code directly for ruby libs so I added the following to the top of my script to act as a patch:
module Net
class HTTP
def use_ssl=(flag)
flag = (flag ? true : false)
raise IOError, "use_ssl value changed, but session already started"\
if started? and @use_ssl != flag
if flag and not @ssl_context
@ssl_context = ::OpenSSL::SSL::SSLContext.new
end
@use_ssl = flag
end
end
end
However I'm getting an error:
scripts/get_social_data.rb:27:in `use_ssl=': uninitialized constant OpenSSL (NameError)
Despite having done:
require 'openssl'
at the top of my script.
Why is OpenSSL
not existing even though I'm requiring it?
I'm guessing I'm missing somthing but I honestly can't see it.
EDIT:
Well, I noticed that Openssl (I'm maintaining this project) was in the gemfile, I'm pretty sure it's not supposed to be there, I uninstalled it but It's still not working.
Ok, so, after looking around the internet and trying various things I found a fix for my issue, I had to re-install ruby 1.8.7-p375 using the following command:
RUBY_CONFIGURE_OPTS=--with-openssl-dir= rbenv install 1.8.7-p375
The opensslDir can be found, at least on osx and installed with homebrew like this:
brew list openssl
You'll get a bunch of dir's, just copy the bit that's in all of them, it might look like somthing like this:
/usr/local/Cellar/openssl/1.0.2h