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

rspec-puppet on puppet 6.17 breaks due to removal of default_env #796

Closed
KeithWard opened this issue Jul 14, 2020 · 9 comments
Closed

rspec-puppet on puppet 6.17 breaks due to removal of default_env #796

KeithWard opened this issue Jul 14, 2020 · 9 comments

Comments

@KeithWard
Copy link

KeithWard commented Jul 14, 2020

It looks like default_env was removed in puppet 6.17 - specifically in this commit:

puppetlabs/puppet@94df3c1

This results in an exceptiion similar to the following when rspec tries to run tests:

 Failure/Error: require 'puppetlabs_spec_helper/module_spec_helper'
 NameError:
   undefined local variable or method `default_env' for Puppet::Util:Module
 # ./vendor/bundle/ruby/2.5.0/gems/rspec-puppet-2.7.8/lib/rspec-puppet/monkey_patches.rb:139:in `get_env'
 # ./vendor/bundle/ruby/2.5.0/gems/puppet-6.17.0/lib/puppet/node/environment.rb:501:in `extralibs'
 # ./vendor/bundle/ruby/2.5.0/gems/puppet-6.17.0/lib/puppet/node/environment.rb:76:in `initialize'
 # ./vendor/bundle/ruby/2.5.0/gems/puppet-6.17.0/lib/puppet/node/environment.rb:43:in `new'
 # ./vendor/bundle/ruby/2.5.0/gems/puppet-6.17.0/lib/puppet/node/environment.rb:43:in `create'
 # ./vendor/bundle/ruby/2.5.0/gems/puppet-6.17.0/lib/puppet.rb:240:in `base_context'
 # ./vendor/bundle/ruby/2.5.0/gems/puppet-6.17.0/lib/puppet/test/test_helper.rb:53:in `initialize'
 # ./vendor/bundle/ruby/2.5.0/gems/rspec-puppet-2.7.8/lib/rspec-puppet.rb:77:in `block in <top (required)>'
 # ./vendor/bundle/ruby/2.5.0/gems/rspec-puppet-2.7.8/lib/rspec-puppet.rb:34:in `<top (required)>'
 # ./vendor/bundle/ruby/2.5.0/gems/puppetlabs_spec_helper-2.15.0/lib/puppetlabs_spec_helper/module_spec_helper.rb:1:in `require'
 # ./vendor/bundle/ruby/2.5.0/gems/puppetlabs_spec_helper-2.15.0/lib/puppetlabs_spec_helper/module_spec_helper.rb:1:in `<top (required)>'
 # ./spec/spec_helper.rb:7:in `require'
 # ./spec/spec_helper.rb:7:in `<top (required)>'

Not sure about what way to go about fixing this.

@edestecd
Copy link

Same on puppet 5.5.21

@edestecd
Copy link

edestecd commented Jul 14, 2020

An error occurred while loading ./spec/classes/profile_core_spec.rb.
Failure/Error: require 'puppetlabs_spec_helper/module_spec_helper'
NameError:
  undefined local variable or method `default_env' for Puppet::Util:Module
# ./vendor/bundle/ruby/2.4.0/gems/rspec-puppet-2.7.8/lib/rspec-puppet/monkey_patches.rb:139:in `get_env'
# ./vendor/bundle/ruby/2.4.0/gems/puppet-5.5.21/lib/puppet/node/environment.rb:512:in `extralibs'
# ./vendor/bundle/ruby/2.4.0/gems/puppet-5.5.21/lib/puppet/node/environment.rb:50:in `create'
# ./vendor/bundle/ruby/2.4.0/gems/puppet-5.5.21/lib/puppet.rb:209:in `base_context'
# ./vendor/bundle/ruby/2.4.0/gems/puppet-5.5.21/lib/puppet/test/test_helper.rb:53:in `initialize'
# ./vendor/bundle/ruby/2.4.0/gems/rspec-puppet-2.7.8/lib/rspec-puppet.rb:77:in `block in <top (required)>'
# ./vendor/bundle/ruby/2.4.0/gems/rspec-puppet-2.7.8/lib/rspec-puppet.rb:34:in `<top (required)>'
# ./vendor/bundle/ruby/2.4.0/gems/puppetlabs_spec_helper-2.15.0/lib/puppetlabs_spec_helper/module_spec_helper.rb:1:in `require'
# ./vendor/bundle/ruby/2.4.0/gems/puppetlabs_spec_helper-2.15.0/lib/puppetlabs_spec_helper/module_spec_helper.rb:1:in `<top (required)>'
# ./spec/spec_helper.rb:5:in `require'
# ./spec/spec_helper.rb:5:in `<top (required)>'
# ./spec/classes/profile_core_spec.rb:3:in `require'
# ./spec/classes/profile_core_spec.rb:3:in `<top (required)>'
No examples found.
Finished in 0.00004 seconds (files took 1.57 seconds to load)
0 examples, 0 failures, 1 error occurred outside of examples

@nmaludy
Copy link

nmaludy commented Jul 14, 2020

+1 same problem here

@sgnn7
Copy link
Contributor

sgnn7 commented Jul 14, 2020

Got a quick fix for this up in a PR that hopefully someone from the maintainers can validate and/or improve since this is my first time dabbling in this repo: #797

sgnn7 added a commit to cyberark/conjur-puppet that referenced this issue Jul 15, 2020
There were upstream issues with broken dependencies that we upstreamed a
fix for and because of this we needed to pin to latest (unreleased)
version of `rspec-puppet` gem. In the process, it seems like we also
discovered that our fork was not required as the tests all pass so it
was likely that we just had a fork to have a pre-release features ready
which are now in mainline.

Upstream bug: rodjek/rspec-puppet#796
Upstream fix: rodjek/rspec-puppet#797
scotje pushed a commit that referenced this issue Jul 15, 2020
Since this is now changed to `DEFAULT_ENV`, we now create the old
function alias to retain functionality.

Bug: #796
Upstream: https://github.com/puppetlabs/puppet/blob/94df3c1a3992d89b2d7d5db8a70373c135bdd86b/lib/puppet/util.rb
@joshcooper
Copy link
Contributor

@dlucredativ
Copy link

dlucredativ commented Jul 17, 2020

@sgnn7 @scotje was it intentional that 2.7.10 bases on 2.7.8 and not 2.7.9?

@sgnn7
Copy link
Contributor

sgnn7 commented Jul 17, 2020

was it intentional that 2.7.10 bases on 2.7.8 and not 2.7.9?

@dlucredativ I don't know enough about this gem to answer that - the fix is independent of the base version though

@dlucredativ
Copy link

was it intentional that 2.7.10 bases on 2.7.8 and not 2.7.9?

@dlucredativ I don't know enough about this gem to answer that - the fix is independent of the base version though

Ok it seems that you only created 73fbbe2 and @scotje cherry-picked it into b6807eb. I just don't know why.

@scotje
Copy link
Collaborator

scotje commented Jul 17, 2020

2.7.9 unintentionally included commits intended for 2.8.x (or 3.x) as they break some peoples existing tests. We yanked the 2.7.9 release and released 2.7.10 which is just 2.7.8 plus only the fix for default_env.

@scotje scotje closed this as completed Jul 17, 2020
gsparks added a commit to gsparks/puppetlabs-splunk_hec that referenced this issue Jul 27, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

7 participants