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

Incompatability with ruby 3.1.0 #325

Closed
rweigle opened this issue Jan 20, 2022 · 7 comments · Fixed by #329
Closed

Incompatability with ruby 3.1.0 #325

rweigle opened this issue Jan 20, 2022 · 7 comments · Fixed by #329

Comments

@rweigle
Copy link

rweigle commented Jan 20, 2022

I tried to install hiera-eyaml on my M1 Mac and got the following error using ruby 3.1.0:

undefined method `dependencies' for #<Gem::StubSpecification:0x0000000104eb38e0 @extension_dir=nil, @full_gem_path=nil, @gem_dir=nil, @ignored=nil, @loaded_from="/Users/m214042/.rbenv/versions/3.1.0/lib/ruby/gems/3.1.0/specifications/CFPropertyList-3.0.5.gemspec", @data=#<Gem::StubSpecification::StubLine:0x0000000104eb1838 @name="CFPropertyList", @version=#<Gem::Version "3.0.5">, @platform="ruby", @extensions=[], @full_name="CFPropertyList-3.0.5", @require_paths=["lib"]>, @name=nil, @spec=nil, @base_dir="/Users/m214042/.rbenv/versions/3.1.0/lib/ruby/gems/3.1.0", @gems_dir="/Users/m214042/.rbenv/versions/3.1.0/lib/ruby/gems/3.1.0/gems", @default_gem=false> (NoMethodError)

              dependency = spec.dependencies.find { |d| d.name == "hiera-eyaml" }
                               ^^^^^^^^^^^^^

Switching back to ruby 2.7.5. resolved the issue for me.

@bastelfreak
Copy link
Member

It's also not compatible with Ruby 3.0: #326

@robeke
Copy link

robeke commented Feb 6, 2022

Although there are ways to work around this, making this compatible with Ruby 3.0+ will be helpful as some Linux distributions have moved to Ruby 3.x and no longer maintain Ruby 2.x packages.

@bastelfreak
Copy link
Member

I totally agree. I currentl do not have a lot of time. Are you able to provide a PR for this?

@robeke
Copy link

robeke commented Feb 13, 2022 via email

@alexjfisher
Copy link
Member

It's also not compatible with Ruby 3.0: #326

The build failure there is because Puppet 6 is not ruby 3.0 compatible. Perhaps it passes with 7 though?

@fredrikt
Copy link

I'm really not a Ruby programmer, nor do I have a desire to become one, but given the clues in rubygems/rubygems#5235 (comment) I was able to get eyaml working on Ubuntu 22.04 (not yet released) with Ruby 3.0.2p107 with this simple change:

--- hiera-eyaml-3.2.2/lib/hiera/backend/eyaml/plugins.rb.bak   2022-03-29 09:18:56.354443976 +0000
+++ hiera-eyaml-3.2.2/lib/hiera/backend/eyaml/plugins.rb       2022-03-29 10:07:16.748199666 +0000
@@ -34,7 +34,7 @@
             specs.each do |spec|
               next if @@plugins.include? spec
 
-              dependency = spec.dependencies.find { |d| d.name == "hiera-eyaml" }
+              dependency = spec.to_spec.dependencies.find { |d| d.name == "hiera-eyaml" }
               next if dependency && !dependency.requirement.satisfied_by?( this_version )
 
               file = nil

I hope someone with real Ruby knowledge can take on from here and make a proper PR. I'm sure there are backwards compatibility issues to handle here.

@rvstaveren
Copy link

Chiming in from a FreeBSD perspective, hiera-eyaml still uses ruby 2.7, but the recently updated ruby27-gems sits at 3.3.7 causing a similar breakage (Bug 262351 - sysutils/rubygem-hiera-eyaml: broken)


eyaml encrypt -p                                                               git:(production|…32   
Traceback (most recent call last):                                                                                                 
        7: from /usr/local/bin/eyaml:25:in `<main>'                                                                                
        6: from /usr/local/bin/eyaml:25:in `load'                                                                                  
        5: from /usr/local/lib/ruby/gems/2.7/gems/hiera-eyaml-3.2.2/bin/eyaml:10:in `<top (required)>'                             
        4: from /usr/local/lib/ruby/gems/2.7/gems/hiera-eyaml-3.2.2/lib/hiera/backend/eyaml/plugins.rb:31:in `find'                
        3: from /usr/local/lib/ruby/gems/2.7/gems/hiera-eyaml-3.2.2/lib/hiera/backend/eyaml/plugins.rb:31:in `each'                
        2: from /usr/local/lib/ruby/gems/2.7/gems/hiera-eyaml-3.2.2/lib/hiera/backend/eyaml/plugins.rb:34:in `block in find'       
        1: from /usr/local/lib/ruby/gems/2.7/gems/hiera-eyaml-3.2.2/lib/hiera/backend/eyaml/plugins.rb:34:in `each'                
/usr/local/lib/ruby/gems/2.7/gems/hiera-eyaml-3.2.2/lib/hiera/backend/eyaml/plugins.rb:37:in `block (2 levels) in find': undefined 
method `dependencies' for #<Gem::StubSpecification:0x0000000805bc8c40> (NoMethodError)     

I made a crude patch but I’m not sure about which version of rubygems (gem::VERSION) introduced the regression. It is similar to @fredrikt ‘s one, but tries to be a bit more forward/backwards compatible with regards to different ruby/rubygem versions. It also follows a similar pattern seen some lines above this patch.

--- /usr/local/lib/ruby/gems/2.7/gems/hiera-eyaml-3.2.2/lib/hiera/backend/eyaml/plugins.rb.orig 2022-03-30 19:25:36.581974000 +0200
+++ /usr/local/lib/ruby/gems/2.7/gems/hiera-eyaml-3.2.2/lib/hiera/backend/eyaml/plugins.rb      2022-03-30 19:30:40.726838000 +0200
@@ -33,6 +33,7 @@
 
             specs.each do |spec|
               next if @@plugins.include? spec
+              spec = Gem::VERSION >= "3.3.7" ? spec.to_spec() : spec
 
               dependency = spec.dependencies.find { |d| d.name == "hiera-eyaml" }
               next if dependency && !dependency.requirement.satisfied_by?( this_version )

Would this be the preferred way to fix this?

Best regards,
Ruben

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

6 participants