FS#70306 - [puppet] incompatiblity with ruby 3.x due to URI.escape
Attached to Project:
Community Packages
Opened by Simon Peeters (SimonPe) - Monday, 05 April 2021, 19:29 GMT
Last edited by Tim (bastelfreak) - Friday, 21 May 2021, 10:10 GMT
Opened by Simon Peeters (SimonPe) - Monday, 05 April 2021, 19:29 GMT
Last edited by Tim (bastelfreak) - Friday, 21 May 2021, 10:10 GMT
|
Details
Description:
puppet upstream (even 7.5) is currently incompatible with ruby 3.x due to usage of `URI.escape`. It seems like upstream has put this on the backburner: https://tickets.puppetlabs.com/browse/PUP-10535 Steps to reproduce: run any puppet command, like `puppet apply -e 'notify {"test":}'`. the result is: ``` /usr/lib/ruby/vendor_ruby/3.0.0/puppet/util.rb:476:in `uri_encode': undefined method `escape' for URI:Module (NoMethodError) from /usr/lib/ruby/vendor_ruby/3.0.0/puppet/util.rb:344:in `path_to_uri' from /usr/lib/ruby/vendor_ruby/3.0.0/puppet/pops/model/ast.rb:4957:in `register_pcore_types' from /usr/lib/ruby/vendor_ruby/3.0.0/puppet/pops.rb:120:in `<module:Puppet>' from /usr/lib/ruby/vendor_ruby/3.0.0/puppet/pops.rb:1:in `<top (required)>' from <internal:/usr/lib/ruby/3.0.0/rubygems/core_ext/kernel_require.rb>:85:in `require' from <internal:/usr/lib/ruby/3.0.0/rubygems/core_ext/kernel_require.rb>:85:in `require' from /usr/lib/ruby/vendor_ruby/3.0.0/puppet/parser/compiler.rb:8:in `<top (required)>' from <internal:/usr/lib/ruby/3.0.0/rubygems/core_ext/kernel_require.rb>:85:in `require' from <internal:/usr/lib/ruby/3.0.0/rubygems/core_ext/kernel_require.rb>:85:in `require' from /usr/lib/ruby/vendor_ruby/3.0.0/puppet/parser.rb:6:in `<top (required)>' from <internal:/usr/lib/ruby/3.0.0/rubygems/core_ext/kernel_require.rb>:85:in `require' from <internal:/usr/lib/ruby/3.0.0/rubygems/core_ext/kernel_require.rb>:85:in `require' from /usr/lib/ruby/vendor_ruby/3.0.0/puppet.rb:360:in `<top (required)>' from <internal:/usr/lib/ruby/3.0.0/rubygems/core_ext/kernel_require.rb>:85:in `require' from <internal:/usr/lib/ruby/3.0.0/rubygems/core_ext/kernel_require.rb>:85:in `require' from /usr/lib/ruby/vendor_ruby/3.0.0/puppet/util/command_line.rb:12:in `<top (required)>' from <internal:/usr/lib/ruby/3.0.0/rubygems/core_ext/kernel_require.rb>:85:in `require' from <internal:/usr/lib/ruby/3.0.0/rubygems/core_ext/kernel_require.rb>:85:in `require' from /usr/bin/puppet:4:in `<main>' ``` possible fixes: - either we package puppet against community-testing/ruby2.7 (so we're on a similar ruby version as the official AIO packages.) - or we patch around the issue here: ``` diff --git a/lib/puppet/util.rb b/lib/puppet/util.rb index db1aa64006..11b153978d 100644 --- a/lib/puppet/util.rb +++ b/lib/puppet/util.rb @@ -473,7 +473,7 @@ module Util orig_verbose = $VERBOSE $VERBOSE = nil unless Puppet::Util::Platform.jruby? begin - encoded += URI.escape(parts[:path]) unless parts[:path].nil? + encoded += URI::DEFAULT_PARSER.escape(parts[:path]) unless parts[:path].nil? ensure $VERBOSE = orig_verbose unless Puppet::Util::Platform.jruby? end ``` |
This task depends upon
```
encoded += URI.escape(parts[:path]) unless parts[:path].nil?
```
with
```
encoded += URI::DEFAULT_PARSER.escape(parts[:path]) unless parts[:path].nil?
```
Info: Retrieving pluginfacts
Error: /File[/var/lib/puppet/facts.d]: Failed to generate additional resources using 'eval_generate': undefined method `unescape' for URI:Module
Error: /File[/var/lib/puppet/facts.d]: Could not evaluate: Could not retrieve file metadata for puppet:///pluginfacts: undefined method `unescape' for URI:Module
Info: Retrieving plugin
Error: /File[/var/lib/puppet/lib]: Failed to generate additional resources using 'eval_generate': undefined method `unescape' for URI:Module
Error: /File[/var/lib/puppet/lib]: Could not evaluate: Could not retrieve file metadata for puppet:///plugins: undefined method `unescape' for URI:Module
Info: Retrieving locales
Error: /File[/var/lib/puppet/locales]: Failed to generate additional resources using 'eval_generate': undefined method `unescape' for URI:Module
Error: /File[/var/lib/puppet/locales]: Could not evaluate: Could not retrieve file metadata for puppet:///locales: undefined method `unescape' for URI:Module
```
pacman -U /var/cache/pacman/pkg/puppet-6.21.1-1-any.pkg.tar.zst /var/cache/pacman/pkg/rubygems-3.2.7-1-any.pkg.tar.zst /var/cache/pacman/pkg/ruby-reline-0.2.2-1-any.pkg.tar.zst /var/cache/pacman/pkg/ruby-irb-1.3.0-1-any.pkg.tar.zst /var/cache/pacman/pkg/ruby-2.7.2-1-x86_64.pkg.tar.zst /var/cache/pacman/pkg/ruby-semantic_puppet-1.0.3-1-any.pkg.tar.zst /var/cache/pacman/pkg/ruby-augeas-0.5.0-4-x86_64.pkg.tar.xz /var/cache/pacman/pkg/ruby-shadow-2.5.0-5-x86_64.pkg.tar.xz /var/cache/pacman/pkg/ruby-concurrent-1.1.8-1-any.pkg.tar.zst /var/cache/pacman/pkg/ruby-multi_json-1.15.0-1-any.pkg.tar.zst /var/cache/pacman/pkg/ruby-hocon-1.3.1-1-any.pkg.tar.zst /var/cache/pacman/pkg/ruby-puppet-resource_api-1.8.13-1-any.pkg.tar.zst /var/cache/pacman/pkg/ruby-httpclient-2.8.3-7-any.pkg.tar.zst /var/cache/pacman/pkg/ruby-deep_merge-1.2.1-2-any.pkg.tar.zst /var/cache/pacman/pkg/ruby-sync-0.5.0-3-any.pkg.tar.zst
```
return URI::DEFAULT_PARSER.unescape(path)
I think after that you might be home free.
Puppet development at the moment, by definition, presumes the underlying Ruby engine is Ruby 2.7. This needs to be adjusted or massive swathes of ruby code in commonly-accepted-working modules will fail.
as soon as I've some free time I will rebuild the package to use Ruby 2.7. There are multiple upstream issues with Ruby 3.0 and it doesn't look like they will be fixed soonish.
Just a remark about puppet-agent (the «agent» part), the official (meaning from puppetlabs) pkg for Debian/CentOS/etc are install in /opt and come with everything need by the puppet (ruby, facter, etc..) I know it's a bulky pkg and not very efficient (in disk usage) way to manage pkg. But on every day using it's very convenient, because puppet-agent can use it's own version of puppet and the OS his version without any conflict.
I pushed a new puppet package to community-testing thats build against Ruby 2.7. I'm still testing it. If one of you wants to test it as well that would be nice.
Admittedly, I didn't do any in-depth testing. I just ran my usual `sudo puppet agent --test` to apply my config changes, and there were no errors.
I didn't notice any missing facts, results looked normal. I don't have a json of facts from before the ruby update to just diff and be sure, so no guarantees.
I moved all the packages to community. Please raise a new issue if you run into issues. In addition we will remove the puppet5 package. I think people had enough time to transition to Puppet 6 now and puppet 5 is EoL and doesn't receive updates anymore.