socketry / nio4r

Cross-platform asynchronous I/O primitives for scalable network clients and servers.
Other
965 stars 86 forks source link

OpenSSL tests fail - uninitialized constant OpenSSL #283

Closed Segaja closed 1 year ago

Segaja commented 2 years ago
/usr/bin/ruby -I/usr/lib/ruby/gems/3.0.0/gems/rspec-support-3.10.2/lib:/usr/lib/ruby/gems/3.0.0/gems/rspec-core-3.10.1/lib /usr/lib/ruby/gems/3.0.0/gems/rspec-core-3.10.1/exe/rspec --pattern spec/\*\*\{,/\*/\*\*\}/\*_spec.rb

An error occurred while loading ./spec/nio/selectables/ssl_socket_spec.rb.
Failure/Error:
  RSpec.describe OpenSSL::SSL::SSLSocket do

    require "openssl"

    before(:all) do
      @tls = []
    end

    let(:addr) { "127.0.0.1" }

NameError:
  uninitialized constant OpenSSL
# ./spec/nio/selectables/ssl_socket_spec.rb:5:in `<top (required)>'

Finished in 0.00003 seconds (files took 0.08354 seconds to load)
0 examples, 0 failures, 1 error occurred outside of examples

/usr/bin/ruby -I/usr/lib/ruby/gems/3.0.0/gems/rspec-support-3.10.2/lib:/usr/lib/ruby/gems/3.0.0/gems/rspec-core-3.10.1/lib /usr/lib/ruby/gems/3.0.0/gems/rspec-core-3.10.1/exe/rspec --pattern spec/\*\*\{,/\*/\*\*\}/\*_spec.rb failed

I guess the require "openssl" block should be outside of this block.

Segaja commented 1 year ago

bump

ioquatix commented 1 year ago

Do you mind making a PR? Thanks!

voxik commented 1 year ago

https://github.com/socketry/nio4r/pull/239/commits/e53e5d518962686e8ca093ee814739b1fa7edf25 is the root cause for the issue. The question is if it should be reverted, or if the constant should be pre-defined outside of the block. But revert is probably easier solution.

MSP-Greg commented 1 year ago

Boy, that was stupid (I authored the commit). Don't recall. I think the intent was to not load openssl when the spec files load, so some specs may run without openssl being loaded. Maybe change

RSpec.describe OpenSSL::SSL::SSLSocket do

to

RSpec.describe 'OpenSSL::SSL::SSLSocket' do
Segaja commented 1 year ago

Will this be patched in the code soon, @MSP-Greg ?

MSP-Greg commented 1 year ago

@Segaja Not sure. If the above is used, other specs can be run without loading Ruby's OpenSSL. Not sure if that's helpful.

Happy to do a PR with the above...

Segaja commented 1 year ago

@MSP-Greg I can confirm the fix above with the quotes works. For now I patch it manually in the build for arch, but it would be nice if it would be fixed in the project itself.

ioquatix commented 1 year ago

I've fixed this by moving the require to before the describe block.