Project

General

Profile

Bug #17330

Initially seeding the database fails with "TypeError: can't dup NilClass"

Added by Guido Günther over 5 years ago. Updated almost 4 years ago.

Status:
Closed
Priority:
Normal
Assignee:
Category:
DB migrations
Target version:
Difficulty:
Triaged:
Bugzilla link:
Fixed in Releases:
Found in Releases:

Description

Following the instructions at https://theforeman.org/contribute.html I do

rm db/*.sqlite3
cp config/settings.yaml.example config/settings.yaml
bundle exec bin/rake db:migrate
bundle exec bin/rake db:seed

The last step fails with:

2016-11-14T21:36:36 [app] [W] unknown class ExternalUsergroups, ignoring | NameError: uninitialized constant ExternalUsergroups | /var/scratch/src/foreman/foreman/vendor/bundle/ruby/2.3.0/gems/activesupport-4.2.7.1/lib/active_support/inflector/methods.rb:261:in `const_get' | /var/scratch/src/foreman/foreman/vendor/bundle/ruby/2.3.0/gems/activesupport-4.2.7.1/lib/active_support/inflector/methods.rb:261:in `block in constantize' | /var/scratch/src/foreman/foreman/vendor/bundle/ruby/2.3.0/gems/activesupport-4.2.7.1/lib/active_support/inflector/methods.rb:259:in `each'

Full log attached.

seed-failure.log seed-failure.log 77.9 KB Guido Günther, 11/14/2016 03:39 PM

Related issues

Related to Foreman - Bug #16204: NameError: uninitialized constant ExternalUsergroupsClosed2016-08-19

Associated revisions

Revision f2c05b8d (diff)
Added by Marek Hulán over 5 years ago

Fixes #17330 - skip admin email if it's unknown

When admin user is being seeded the Setting might not exist at that
moment. We can't just create it with value, since the setting would
be invalid because of other attributes. Therefore we split settings
creation from the setting list so we could create it from seed too.

This also fixes first_or_create calls that was broken by overrind the
create method. The setting was missing name since we didn't call new
method on Relation object.

History

#1 Updated by Marek Hulán over 5 years ago

What version of Foreman have you installed? First warning appears on call at 03-roles.rb on line 63 when it tries to create the role for external usergroups. I suppose it's because permissions define resource type as ExternalUsergroups instead of ExternalUsergroup (singular), this was present since Foreman 1.7 (introduced in #3976) and is ignored.

The error causing the task to fail is this

rake aborted!
TypeError: can't dup NilClass
/var/scratch/src/foreman/foreman/db/seeds.d/04-admin.rb:38:in `dup'
/var/scratch/src/foreman/foreman/db/seeds.d/04-admin.rb:38:in `block (2 levels) in <top (required)>'

As an easy workaround, set SEED_ADMIN_EMAIL variable to email address for your admin user and rerun the task, e.g.

SEED_ADMIN_EMAIL=admin@example.com bundle exec bin/rake db:seed

#2 Updated by The Foreman Bot over 5 years ago

  • Status changed from New to Ready For Testing
  • Assignee set to Marek Hulán
  • Pull request https://github.com/theforeman/foreman/pull/4020 added

#3 Updated by Sebastian Gräßl over 5 years ago

I can confirm this error, but the "error" in question should according to Dominic's note (http://projects.theforeman.org/issues/16204#note-1) not be treated as such.

My suggestion would be to look into omitting the backtrace, when it is a warning to not raise confusion about it being something to worry about.

Plus, an explanation why it is "ignorable" would make sense here as well, maybe.

#4 Updated by Dominic Cleal over 5 years ago

  • Related to Bug #16204: NameError: uninitialized constant ExternalUsergroups added

#5 Updated by Dominic Cleal over 5 years ago

  • Subject changed from Initially seeding the database failes to Initially seeding the database fails with "TypeError: can't dup NilClass"

This ticket's about the error "TypeError: can't dup NilClass" causing a failure, the warning didn't cause the failure and can be addressed under #16204.

#6 Updated by Guido Günther over 5 years ago

Marek Hulán wrote:

As an easy workaround, set SEED_ADMIN_EMAIL variable to email address for your admin user and rerun the task, e.g.

I can confirm this works.

#7 Updated by Marek Hulán over 5 years ago

  • Status changed from Ready For Testing to Closed
  • % Done changed from 0 to 100

#8 Updated by Marek Hulán over 5 years ago

  • Target version set to 1.11.2

#9 Updated by Dominic Cleal over 5 years ago

  • Legacy Backlogs Release (now unused) set to 209

Also available in: Atom PDF