Fix Gem::Specification#to_ruby without OpenSSL#3059
Fix Gem::Specification#to_ruby without OpenSSL#3059alyssais wants to merge 1 commit intoruby:masterfrom
Conversation
OpenSSL is an optional dependency of Ruby. Requiring openssl unconditionally means that Rubies that don't have the OpenSSL library won't be able to use RubyGems at all. In such a Ruby, an OpenSSL::PKey::RSA object can't exist, so we can just skip the check for those objects if there is no OpenSSL.
|
This require was added at #2937. Is Ruby without openssl supported by rubygems? Simple search for openssl at github (https://github.com/rubygems/rubygems/search?p=1&q=OpenSSL&unscoped_q=OpenSSL) shows different approaches how to handle OpenSSL presence. |
zimbatm
left a comment
There was a problem hiding this comment.
an idea to make the relationship between both code blocks more explicit
| def to_ruby | ||
| require 'openssl' | ||
| begin | ||
| require 'openssl' |
There was a problem hiding this comment.
| require 'openssl' | |
| require 'openssl' | |
| has_openssl = true |
| require 'openssl' | ||
| begin | ||
| require 'openssl' | ||
| rescue LoadError |
There was a problem hiding this comment.
| rescue LoadError | |
| rescue LoadError | |
| has_openssl = false |
| current_value = self.send(attr_name) | ||
| if current_value != default_value(attr_name) || self.class.required_attribute?(attr_name) | ||
| result << " s.#{attr_name} = #{ruby_code current_value}" unless current_value.is_a?(OpenSSL::PKey::RSA) | ||
| unless defined?(OpenSSL) && current_value.is_a?(OpenSSL::PKey::RSA) |
There was a problem hiding this comment.
| unless defined?(OpenSSL) && current_value.is_a?(OpenSSL::PKey::RSA) | |
| unless has_openssl && current_value.is_a?(OpenSSL::PKey::RSA) |
There was a problem hiding this comment.
i prefer keeping consistent with the library by checking for the constant
|
@simi ruby is shipping with rubygems right? If ruby can have openssl disabled then rubygems should probably also support it at least for basic functionality. |
|
@simi ruby is shipping with rubygems right? If ruby can have openssl
disabled then rubygems should probably also support it at least for
basic functionality.
Correct. Because of this method, installing Ruby 2.7 at all without
OpenSSL is broken.
|
|
See https://bugs.ruby-lang.org/issues/16475 I think that rubygems does not have to seriously support an environment without openssl, but I want |
|
Just to give a use-case: a small ruby script that I want to distribute with a minimal installation of ruby. The script just uses the ruby stdlib and doesn't need network access so OpenSSL is not needed. |
Description:
OpenSSL is an optional dependency of Ruby. Requiring openssl
unconditionally means that Rubies that don't have the OpenSSL library
won't be able to use RubyGems at all.
In such a Ruby, an OpenSSL::PKey::RSA object can't exist, so we can
just skip the check for those objects if there is no OpenSSL.
Tasks:
I will abide by the code of conduct.