Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Forcibly load OpenSSL to handle autoloading issues in net/http/persis… #37

Closed
wants to merge 1 commit into from

Conversation

dreilly1982
Copy link

Forcibly require OpenSSL, because net/http/persistent will only autoload it. On some Rubies, autoload fails but explicit require succeeds. This is to resolve #36

@raggi
Copy link
Collaborator

raggi commented Jul 28, 2015

Please can you provide some more details as to how this happens?

In net/http/persistent there is a reference to OpenSSL after the autoload statement that should always trigger an autoload. It will fail if OpenSSL is not in the lib path, e.g. if somehow openssl was in a non-bundled gem.

Can you at minimum expand on "some Rubies" ?

@dreilly1982
Copy link
Author

I wish I had a better answer, I found this solution in rubygems/bundler#3107. As stated in issue #36 SSL autoloading was not working. My Ruby version on the machine in question is 2.2.2p95. This can be seen with the following code:

irb(main):001:0> autoload :OpenSSL, 'openssl'
=> nil
irb(main):002:0> defined? OpenSSL::SSL
=> nil
irb(main):003:0> require 'openssl'
=> true
irb(main):004:0> defined? OpenSSL::SSL
=> "constant"

On other versions of Ruby on different machines (even some running 2.2.2p95) autoloading works as intended:

:001 > autoload :OpenSSL, 'openssl'
 => nil 
 :002 > defined? OpenSSL::SSL
 => "constant" 

I know this is an edge case, that probably isn't very easy to reproduce, but it was an issue fixed by forcing the loading of OpenSSL.

@raggi
Copy link
Collaborator

raggi commented Jul 29, 2015

Has this been reported to net/http/persistent ?

On Tue, Jul 28, 2015, 7:52 PM Don Reilly [email protected] wrote:

I wish I had a better answer, I found this solution in
rubygems/bundler#3107 rubygems/bundler#3107. As
stated in issue #36
#36 SSL autoloading
was not working. My Ruby version on the machine in question is 2.2.2p95.
This can be seen with the following code:

irb(main):001:0> autoload :OpenSSL, 'openssl'
=> nil
irb(main):002:0> defined? OpenSSL::SSL
=> nil
irb(main):003:0> require 'openssl'
=> true
irb(main):004:0> defined? OpenSSL::SSL
=> "constant"

On other versions of Ruby on different machines (even some running
2.2.2p95) autoloading works as intended:

:001 > autoload :OpenSSL, 'openssl'
=> nil
:002 > defined? OpenSSL::SSL
=> "constant"

I know this is an edge case, that probably isn't very easy to reproduce,
but it was an issue fixed by forcing the loading of OpenSSL.


Reply to this email directly or view it on GitHub
#37 (comment)
.

@dreilly1982
Copy link
Author

I opened a ticket with them drbrain/net-http-persistent#70

@@ -1,3 +1,11 @@
# We forcibly require OpenSSL, because net/http/persistent will only autoload
# it. On some Rubies, autoload fails but explicit require succeeds.
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please put a reference to the bug number here.

@olleolleolle
Copy link
Member

The mentioned issue was recently closed.

@raggi raggi closed this Jul 20, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

OpenSSL error
3 participants