samvera-deprecated / sufia

[DEPRECATED] Sufia: a fully featured, flexible Samvera repository front-end.
http://sufia.io/
Other
111 stars 78 forks source link

Error When Deleting Work Type #3162

Open metageeky opened 7 years ago

metageeky commented 7 years ago

Descriptive summary

I was attempting to delete a work type in Sufia 7.3. NOTE: No items had placed in the repository of ANY type. I had previously created the MovingImage type based on the command given in the Sufia README. Using the command rails destroy sufia:work MovingImage as provided by @mjgiarlo, I got the following and the errors:

[vagrant@localhost druw]$ rails destroy sufia:work MovingImage
/usr/lib64/ruby/gems/2.4.0/gems/activesupport-5.0.1/lib/active_support/xml_mini.rb:51: warning: constant ::Fixnum is deprecated
/usr/lib64/ruby/gems/2.4.0/gems/activesupport-5.0.1/lib/active_support/xml_mini.rb:52: warning: constant ::Bignum is deprecated
/usr/lib64/ruby/gems/2.4.0/gems/activesupport-5.0.1/lib/active_support/core_ext/numeric/conversions.rb:138: warning: constant ::Fixnum is deprecated
Running via Spring preloader in process 6653
      remove  spec/models/moving_image_spec.rb
        info  GENERATING WORK MODEL
      remove  app/models/moving_image.rb
      remove  spec/controllers/curation_concerns/moving_images_controller_spec.rb
      remove  spec/actors/curation_concerns/actors/moving_image_actor_spec.rb
      remove  spec/forms/curation_concerns/moving_image_form_spec.rb
      remove  spec/features/create_moving_image_spec.rb
      remove  app/controllers/curation_concerns/moving_images_controller.rb
      remove  app/actors/curation_concerns/actors/moving_image_actor.rb
      remove  app/forms/curation_concerns/moving_image_form.rb
    subtract  config/initializers/sufia.rb
      remove  app/views/curation_concerns/moving_images/_moving_image.html.erb
===============================================================================

After creating your work you may wish to:

  1. Add custom views:

      By default, the views found in
      CurationConcerns::Engine.root/app/views/curation_concerns/base
      will be used.

  2. Modify the model, actor, form or presenter.

===============================================================================
      remove  config/locales/moving_image.en.yml
    subtract  app/models/moving_image.rb
/usr/lib64/ruby/gems/2.4.0/gems/thor-0.19.4/lib/thor/actions/inject_into_file.rb:95:in `binread': No such file or directory @ rb_sysopen - /home/vagrant/druw/app/models/moving_image.rb (Errno::ENOENT)
        from /usr/lib64/ruby/gems/2.4.0/gems/thor-0.19.4/lib/thor/actions/inject_into_file.rb:95:in `replace!'
        from /usr/lib64/ruby/gems/2.4.0/gems/thor-0.19.4/lib/thor/actions/inject_into_file.rb:70:in `revoke!'
        from /usr/lib64/ruby/gems/2.4.0/gems/thor-0.19.4/lib/thor/actions.rb:93:in `action'
        from /usr/lib64/ruby/gems/2.4.0/gems/thor-0.19.4/lib/thor/actions/inject_into_file.rb:27:in `insert_into_file'
        from /usr/lib64/ruby/gems/2.4.0/gems/sufia-7.3.0/lib/generators/sufia/work/work_generator.rb:46:in `inject_sufia_work_behavior'
        from /usr/lib64/ruby/gems/2.4.0/gems/thor-0.19.4/lib/thor/command.rb:27:in `run'
        from /usr/lib64/ruby/gems/2.4.0/gems/thor-0.19.4/lib/thor/invocation.rb:126:in `invoke_command'
        from /usr/lib64/ruby/gems/2.4.0/gems/thor-0.19.4/lib/thor/invocation.rb:133:in `block in invoke_all'
        from /usr/lib64/ruby/gems/2.4.0/gems/thor-0.19.4/lib/thor/invocation.rb:133:in `each'
        from /usr/lib64/ruby/gems/2.4.0/gems/thor-0.19.4/lib/thor/invocation.rb:133:in `map'
        from /usr/lib64/ruby/gems/2.4.0/gems/thor-0.19.4/lib/thor/invocation.rb:133:in `invoke_all'
        from /usr/lib64/ruby/gems/2.4.0/gems/thor-0.19.4/lib/thor/group.rb:232:in `dispatch'
        from /usr/lib64/ruby/gems/2.4.0/gems/thor-0.19.4/lib/thor/base.rb:444:in `start'
        from /usr/lib64/ruby/gems/2.4.0/gems/railties-5.0.1/lib/rails/generators.rb:180:in `invoke'
        from /usr/lib64/ruby/gems/2.4.0/gems/railties-5.0.1/lib/rails/commands/destroy.rb:11:in `<top (required)>'
        from /usr/lib64/ruby/gems/2.4.0/gems/activesupport-5.0.1/lib/active_support/dependencies.rb:293:in `require'
        from /usr/lib64/ruby/gems/2.4.0/gems/activesupport-5.0.1/lib/active_support/dependencies.rb:293:in `block in require'
        from /usr/lib64/ruby/gems/2.4.0/gems/activesupport-5.0.1/lib/active_support/dependencies.rb:259:in `load_dependency'
        from /usr/lib64/ruby/gems/2.4.0/gems/activesupport-5.0.1/lib/active_support/dependencies.rb:293:in `require'
        from /usr/lib64/ruby/gems/2.4.0/gems/railties-5.0.1/lib/rails/commands/commands_tasks.rb:138:in `require_command!'
        from /usr/lib64/ruby/gems/2.4.0/gems/railties-5.0.1/lib/rails/commands/commands_tasks.rb:145:in `generate_or_destroy'
        from /usr/lib64/ruby/gems/2.4.0/gems/railties-5.0.1/lib/rails/commands/commands_tasks.rb:64:in `destroy'
        from /usr/lib64/ruby/gems/2.4.0/gems/railties-5.0.1/lib/rails/commands/commands_tasks.rb:49:in `run_command!'
        from /usr/lib64/ruby/gems/2.4.0/gems/railties-5.0.1/lib/rails/commands.rb:18:in `<top (required)>'
        from /usr/lib64/ruby/gems/2.4.0/gems/activesupport-5.0.1/lib/active_support/dependencies.rb:293:in `require'
        from /usr/lib64/ruby/gems/2.4.0/gems/activesupport-5.0.1/lib/active_support/dependencies.rb:293:in `block in require'
        from /usr/lib64/ruby/gems/2.4.0/gems/activesupport-5.0.1/lib/active_support/dependencies.rb:259:in `load_dependency'
        from /usr/lib64/ruby/gems/2.4.0/gems/activesupport-5.0.1/lib/active_support/dependencies.rb:293:in `require'
        from /home/vagrant/druw/bin/rails:9:in `<top (required)>'
        from /usr/lib64/ruby/gems/2.4.0/gems/activesupport-5.0.1/lib/active_support/dependencies.rb:287:in `load'
        from /usr/lib64/ruby/gems/2.4.0/gems/activesupport-5.0.1/lib/active_support/dependencies.rb:287:in `block in load'
        from /usr/lib64/ruby/gems/2.4.0/gems/activesupport-5.0.1/lib/active_support/dependencies.rb:259:in `load_dependency'
        from /usr/lib64/ruby/gems/2.4.0/gems/activesupport-5.0.1/lib/active_support/dependencies.rb:287:in `load'
        from /usr/lib64/ruby/2.4.0/rubygems/core_ext/kernel_require.rb:55:in `require'
        from /usr/lib64/ruby/2.4.0/rubygems/core_ext/kernel_require.rb:55:in `require'
        from -e:1:in `<main>'

Note that the error appears to be that a subtract is being performed on the file _models/movingimage.rb that was deleted earlier.

Upon restarting the rails server, we also now get the following error in the browser:

Rails.root: /home/vagrant/druw
Application Trace | Framework Trace | Full Trace

app/models/work.rb:4:in `include'
app/models/work.rb:4:in `<class:Work>'
app/models/work.rb:3:in `<top (required)>'
app/helpers/curation_concerns_helper.rb:3:in `<module:CurationConcernsHelper>'
app/helpers/curation_concerns_helper.rb:1:in `<top (required)>'
app/controllers/application_controller.rb:1:in `<top (required)>'

Expected behavior

The MovingImage work type is deleted and everything runs okay.

Actual behavior

The delete work process fails as indicated in the steps above.

Steps to reproduce the behavior

  1. Take a Sufia instance with no items in it. Create work types as per the README instructions:
    rails generate sufia:work Work
    rails generate sufia:work MovingImage
  2. rails destroy sufia:work MovingImage
  3. That gives you the error. To see the browser error, restart the rails server and go to the homepage.

Related work

None

metageeky commented 7 years ago

I was able to fix the uninitialized constant error by removing where the add process had added the constant in config/initializers/sufia.rb. Restarting the rails server made pages work again.

mjgiarlo commented 7 years ago

Thanks for the issue, @metageeky. I did some work related this in Hyrax that makes the work generator clean up after itself.

If anyone is inclined to backport to Sufia or CC, here is that work: https://github.com/projecthydra-labs/hyrax/pull/302/files

There's a bunch there, but this is the line that is probably needed: https://github.com/projecthydra-labs/hyrax/pull/302/files#diff-7ef30fd477089488a34e7266fa4373d7R47