[PUP-1547] PR (2311) Undefined method `groups' for nil:NilClass Created: 2014/01/30  Updated: 2015/06/15  Resolved: 2014/04/14

Status: Closed
Project: Puppet
Component/s: None
Affects Version/s: PUP 3.4.2
Fix Version/s: PUP 3.6.0

Type: Bug Priority: Normal
Reporter: Carlos Sanchez Assignee: Tony Vu
Resolution: Fixed Votes: 2
Labels: None
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified

Template:
Story Points: 1
Sprint: Week 2014-3-12 to 2014-3-19, Week 2014-4-02 to 2014-4-09, Week 2014-4-09 to 2014-4-16

 Description   

Lost quite some time in a rspec-puppet issue due to this error
Ultimately it was due to being on os x and setting operatingsystem fact to centos, making puppet unable to find providers for the user type.

     NoMethodError:
       undefined method `groups' for nil:NilClass
     # /Users/csanchez/.rvm/gems/ruby-1.9.3-p484/gems/puppet-3.4.2/lib/puppet/property/list.rb:57:in `retrieve'
     # /Users/csanchez/.rvm/gems/ruby-1.9.3-p484/gems/puppet-3.4.2/lib/puppet/property/list.rb:46:in `should'
     # /Users/csanchez/.rvm/gems/ruby-1.9.3-p484/gems/puppet-3.4.2/lib/puppet/type/user.rb:359:in `block (2 levels) in <module:Puppet>'



 Comments   
Comment by Carlos Sanchez [ 2014/01/30 ]

PR at https://github.com/puppetlabs/puppet/pull/2311

Comment by Francisco A. Lozano [ 2014/02/06 ]

Having similar problem here, using puppet 3.4.2 (gem-installed) under a centos docker/lxc container. It doesn't reproduce in our rpm-installed EC2 instances.

Error: Got an uncaught exception of type NoMethodError: undefined method `groups' for nil:NilClass
/usr/local/lib/ruby/gems/2.0.0/gems/puppet-3.4.1/lib/puppet/property/list.rb:59:in `retrieve'
/usr/local/lib/ruby/gems/2.0.0/gems/puppet-3.4.1/lib/puppet/property/list.rb:46:in `should'
/usr/local/lib/ruby/gems/2.0.0/gems/puppet-3.4.1/lib/puppet/type/user.rb:359:in `block (2 levels) in <module:Puppet>'
/usr/local/lib/ruby/gems/2.0.0/gems/puppet-3.4.1/lib/puppet/type.rb:1979:in `instance_eval'
/usr/local/lib/ruby/gems/2.0.0/gems/puppet-3.4.1/lib/puppet/type.rb:1979:in `block in autorequire'
/usr/local/lib/ruby/gems/2.0.0/gems/puppet-3.4.1/lib/puppet/type.rb:1957:in `block in eachautorequire'

Comment by Andrew Parker [ 2014/03/12 ]

Joshua Partlow, I think the consensus was the the PR looks OK, but there is a missing test and the commit message needs to have a bit more information explaining what happened before, what changes, and what should now happen.

Comment by Carlos Sanchez [ 2014/03/26 ]

updated the PR commit msg and added a spec

Comment by Tony Vu [ 2014/04/14 ]

Verified spec_tests passed for

bundle exec rspec spec/unit/property/list_spec.rb

Comment by R Tyler [ 2014/05/02 ]

Was there a work-around you discovered to make it possible to continue using rspec-puppet sanely until this fix is in a publicly available Puppet release?

Comment by Carlos Sanchez [ 2014/05/02 ]

yes, mocking some methods,
https://github.com/maestrodev/maestro-puppet-example/blob/master/spec/spec_helper.rb#L19

Comment by Alex Harvey [ 2015/06/15 ]

For anyone else searching for a workaround for earlier versions of Puppet, you can also add a global default in spec/fixtures/manifests/site.pp:

# workaround for https://tickets.puppetlabs.com/browse/PUP-1547
if $::operatingsystem == 'CentOS' {
  User {
    provider => 'useradd',
  }
}

Carlos Sanchez's work around doesn't work on some earlier versions of puppet, e.g. the 3.3.1 system I'm using.

Generated at Fri Dec 13 09:22:42 PST 2019 using JIRA 7.7.1#77002-sha1:e75ca93d5574d9409c0630b81c894d9065296414.