voxpupuli / puppet-alternatives

Manage Debian alternatives links
https://forge.puppet.com/puppet/alternatives
Apache License 2.0
24 stars 35 forks source link

Error: Could not autoload puppet/provider/alternatives/chkconfig #125

Closed hammoumi94 closed 2 years ago

hammoumi94 commented 2 years ago

I have an issue with the last version of puppet module alternatives. I can't fix this issue after the last changes in puppet module alternatives. the error is as below :

Error: Could not autoload puppet/provider/alternatives/chkconfig: /etc/puppetlabs/code/environments/production/modules/alternatives/lib/puppet/provider/alternatives/chkconfig.rb:36: syntax error, unexpected keyword_rescue, expecting keyword_end
==> rescue StandardError
==>            ^
==>/etc/puppetlabs/code/environments/production/modules/alternatives/lib/puppet/provider/alternatives/chkconfig.rb:80: syntax error, unexpected keyword_end, expecting end-of-input
==>Error: Could not autoload puppet/type/alternatives: Could not autoload puppet/provider/alternatives/chkconfig: /etc/puppetlabs/code/environments/production/modules/alternatives/lib/puppet/provider/alternatives/chkconfig.rb:36: syntax error, unexpected keyword_rescue, expecting keyword_end
==> rescue StandardError
==>           ^
==> /etc/puppetlabs/code/environments/production/modules/alternatives/lib/puppet/provider/alternatives/chkconfig.rb:80: syntax error, unexpected keyword_end, expecting end-of-input
==>  Error: Evaluation Error: Error while evaluating a Type-Name, Could not autoload puppet/type/alternatives: Could not autoload puppet/provider/alternatives/chkconfig: /etc/puppetlabs/code/environments/production/modules/alternatives/lib/puppet/provider/alternatives/chkconfig.rb:36: syntax error, unexpected keyword_rescue, expecting keyword_end

Can someone know how to solve this issue ? i tried to solve it with the last version of alternatives 4.1.0 and the previous one 4.0.0 but the error still exist. puppet agent version 5.5.22.

ekohl commented 2 years ago

It appears to be this code: https://github.com/voxpupuli/puppet-alternatives/blob/83e2472ccbbb1e766287972240d20e256e713dac/lib/puppet/provider/alternatives/chkconfig.rb#L29-L40

It is using a syntax that is only valid with Ruby 2.5 while 5.5 ships Ruby 2.4. It was modified in https://github.com/voxpupuli/puppet-alternatives/commit/cf4881ab2859bd01b3bc900a747259c7deea58e0 so 4.0.0 should work. Perhaps it's not properly deployed or not picking up the change?

Either way, the module version 4.x does not support Puppet agent 5. Since Puppet 5 is EOL, I'd recommend upgrading to at least Puppet 6 but preferably to Puppet 7.