prey / gdpr_rails

Rails Engine for the GDPR compliance
https://preyproject.com
MIT License
626 stars 62 forks source link

Rails 6 + Require Paperclip Error? #49

Closed masonhensley closed 4 years ago

masonhensley commented 4 years ago

Came across an error where the gem attempts to require paperclip in a rails 6 environment despite it being set to false.

Question - should require paperclip in gdpr_rails-f8f4e72e3042/app/models/policy_manager/concerns/paperclip_behavior.rb be handled differently for rails 6? Should zeitworks be added as a dep to the package per this post? https://medium.com/cedarcode/understanding-zeitwerk-in-rails-6-f168a9f09a1f

#config/initializers/gdpr_policy_manager.rb
PolicyManager::Config.setup do |config|
  # config.paperclip = false
  # ...

Offending Code Blocks

# ...gems/ruby-2.6.4/bundler/gems/gdpr_rails-f8f4e72e3042/app/models/policy_manager/portability_request.rb
require "aasm"

module PolicyManager
  class PortabilityRequest < ApplicationRecord

    belongs_to :user, class_name: Config.user_resource.to_s, foreign_key:  :user_id

    if PolicyManager::Config.paperclip
      include PolicyManager::Concerns::PaperclipBehavior 
    else
      include PolicyManager::Concerns::ActiveStorageBehavior
    end
# ...
# ... gems/ruby-2.6.4/bundler/gems/gdpr_rails-f8f4e72e3042/app/models/policy_manager/concerns/paperclip_behavior.rb

# -*- encoding : utf-8 -*-
require "paperclip"

module PolicyManager::Concerns::PaperclipBehavior
  extend ActiveSupport::Concern
  include Paperclip::Glue

  included do
# ...

Log Line of Significance

from /usr/local/bundle/ruby/2.6.0/bundler/gems/gdpr_rails-f8f4e72e3042/app/models/policy_manager/concerns/paperclip_behavior.rb:2:in `<main>'

Full Logs

, [2020-01-28T21:16:14.127792 #1]  INFO -- sentry: ** [Raven] Raven 2.13.0 ready to catch errors
=> Booting Puma
=> Rails 6.0.2.1 application starting in production 
=> Run `rails server --help` for more startup options
I, [2020-01-28T21:16:15.650386 #1]  INFO -- : Raven 2.13.0 ready to catch errors
Exiting
/usr/local/bundle/ruby/2.6.0/gems/bootsnap-1.4.5/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:33:in `require': cannot load such file -- paperclip (LoadError)
    from /usr/local/bundle/ruby/2.6.0/gems/zeitwerk-2.2.2/lib/zeitwerk/kernel.rb:23:in `require'
    from /usr/local/bundle/ruby/2.6.0/bundler/gems/gdpr_rails-f8f4e72e3042/app/models/policy_manager/concerns/paperclip_behavior.rb:2:in `<main>'
    from /usr/local/bundle/ruby/2.6.0/gems/bootsnap-1.4.5/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:22:in `require'
    from /usr/local/bundle/ruby/2.6.0/gems/bootsnap-1.4.5/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:22:in `block in require_with_bootsnap_lfi'
    from /usr/local/bundle/ruby/2.6.0/gems/bootsnap-1.4.5/lib/bootsnap/load_path_cache/loaded_features_index.rb:92:in `register'
    from /usr/local/bundle/ruby/2.6.0/gems/bootsnap-1.4.5/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:21:in `require_with_bootsnap_lfi'
    from /usr/local/bundle/ruby/2.6.0/gems/bootsnap-1.4.5/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:30:in `require'
    from /usr/local/bundle/ruby/2.6.0/gems/zeitwerk-2.2.2/lib/zeitwerk/kernel.rb:16:in `require'
    from /usr/local/bundle/ruby/2.6.0/gems/zeitwerk-2.2.2/lib/zeitwerk/loader.rb:351:in `const_get'
    from /usr/local/bundle/ruby/2.6.0/gems/zeitwerk-2.2.2/lib/zeitwerk/loader.rb:351:in `block (2 levels) in eager_load'
    from /usr/local/bundle/ruby/2.6.0/gems/zeitwerk-2.2.2/lib/zeitwerk/loader.rb:685:in `block in ls'
    from /usr/local/bundle/ruby/2.6.0/gems/zeitwerk-2.2.2/lib/zeitwerk/loader.rb:682:in `foreach'
    from /usr/local/bundle/ruby/2.6.0/gems/zeitwerk-2.2.2/lib/zeitwerk/loader.rb:682:in `ls'
    from /usr/local/bundle/ruby/2.6.0/gems/zeitwerk-2.2.2/lib/zeitwerk/loader.rb:346:in `block in eager_load'
    from /usr/local/bundle/ruby/2.6.0/gems/zeitwerk-2.2.2/lib/zeitwerk/loader.rb:338:in `synchronize'
    from /usr/local/bundle/ruby/2.6.0/gems/zeitwerk-2.2.2/lib/zeitwerk/loader.rb:338:in `eager_load'
    from /usr/local/bundle/ruby/2.6.0/gems/zeitwerk-2.2.2/lib/zeitwerk/loader.rb:449:in `each'
    from /usr/local/bundle/ruby/2.6.0/gems/zeitwerk-2.2.2/lib/zeitwerk/loader.rb:449:in `eager_load_all'
    from /usr/local/bundle/ruby/2.6.0/gems/railties-6.0.2.1/lib/rails/application/finisher.rb:122:in `block in <module:Finisher>'
    from /usr/local/bundle/ruby/2.6.0/gems/railties-6.0.2.1/lib/rails/initializable.rb:32:in `instance_exec'
    from /usr/local/bundle/ruby/2.6.0/gems/railties-6.0.2.1/lib/rails/initializable.rb:32:in `run'
    from /usr/local/bundle/ruby/2.6.0/gems/railties-6.0.2.1/lib/rails/initializable.rb:61:in `block in run_initializers'
    from /usr/local/lib/ruby/2.6.0/tsort.rb:228:in `block in tsort_each'
    from /usr/local/lib/ruby/2.6.0/tsort.rb:350:in `block (2 levels) in each_strongly_connected_component'
    from /usr/local/lib/ruby/2.6.0/tsort.rb:431:in `each_strongly_connected_component_from'
    from /usr/local/lib/ruby/2.6.0/tsort.rb:349:in `block in each_strongly_connected_component'
    from /usr/local/lib/ruby/2.6.0/tsort.rb:347:in `each'
    from /usr/local/lib/ruby/2.6.0/tsort.rb:347:in `call'
    from /usr/local/lib/ruby/2.6.0/tsort.rb:347:in `each_strongly_connected_component'
    from /usr/local/lib/ruby/2.6.0/tsort.rb:226:in `tsort_each'
    from /usr/local/lib/ruby/2.6.0/tsort.rb:205:in `tsort_each'
    from /usr/local/bundle/ruby/2.6.0/gems/railties-6.0.2.1/lib/rails/initializable.rb:60:in `run_initializers'
    from /usr/local/bundle/ruby/2.6.0/gems/railties-6.0.2.1/lib/rails/application.rb:363:in `initialize!'
    from /app/config/environment.rb:5:in `<main>'
    from /usr/local/bundle/ruby/2.6.0/gems/bootsnap-1.4.5/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:22:in `require'
    from /usr/local/bundle/ruby/2.6.0/gems/bootsnap-1.4.5/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:22:in `block in require_with_bootsnap_lfi'
    from /usr/local/bundle/ruby/2.6.0/gems/bootsnap-1.4.5/lib/bootsnap/load_path_cache/loaded_features_index.rb:92:in `register'
    from /usr/local/bundle/ruby/2.6.0/gems/bootsnap-1.4.5/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:21:in `require_with_bootsnap_lfi'
    from /usr/local/bundle/ruby/2.6.0/gems/bootsnap-1.4.5/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:30:in `require'
    from /usr/local/bundle/ruby/2.6.0/gems/zeitwerk-2.2.2/lib/zeitwerk/kernel.rb:23:in `require'
    from /usr/local/bundle/ruby/2.6.0/gems/activesupport-6.0.2.1/lib/active_support/dependencies.rb:325:in `block in require'
    from /usr/local/bundle/ruby/2.6.0/gems/activesupport-6.0.2.1/lib/active_support/dependencies.rb:291:in `load_dependency'
    from /usr/local/bundle/ruby/2.6.0/gems/activesupport-6.0.2.1/lib/active_support/dependencies.rb:325:in `require'
    from /usr/local/bundle/ruby/2.6.0/gems/bootsnap-1.4.5/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:48:in `require_relative'
    from config.ru:3:in `block in <main>'
    from /usr/local/bundle/ruby/2.6.0/gems/rack-2.1.1/lib/rack/builder.rb:71:in `instance_eval'
    from /usr/local/bundle/ruby/2.6.0/gems/rack-2.1.1/lib/rack/builder.rb:71:in `initialize'
    from config.ru:in `new'
    from config.ru:in `<main>'
    from /usr/local/bundle/ruby/2.6.0/gems/rack-2.1.1/lib/rack/builder.rb:65:in `eval'
    from /usr/local/bundle/ruby/2.6.0/gems/rack-2.1.1/lib/rack/builder.rb:65:in `new_from_string'
    from /usr/local/bundle/ruby/2.6.0/gems/rack-2.1.1/lib/rack/builder.rb:59:in `load_file'
    from /usr/local/bundle/ruby/2.6.0/gems/rack-2.1.1/lib/rack/builder.rb:40:in `parse_file'
    from /usr/local/bundle/ruby/2.6.0/gems/rack-2.1.1/lib/rack/server.rb:351:in `build_app_and_options_from_config'
    from /usr/local/bundle/ruby/2.6.0/gems/rack-2.1.1/lib/rack/server.rb:251:in `app'
    from /usr/local/bundle/ruby/2.6.0/gems/rack-2.1.1/lib/rack/server.rb:424:in `wrapped_app'
    from /usr/local/bundle/ruby/2.6.0/gems/rack-2.1.1/lib/rack/server.rb:314:in `block in start'
    from /usr/local/bundle/ruby/2.6.0/gems/rack-2.1.1/lib/rack/server.rb:381:in `handle_profiling'
    from /usr/local/bundle/ruby/2.6.0/gems/rack-2.1.1/lib/rack/server.rb:313:in `start'
    from /usr/local/bundle/ruby/2.6.0/gems/railties-6.0.2.1/lib/rails/commands/server/server_command.rb:39:in `start'
    from /usr/local/bundle/ruby/2.6.0/gems/railties-6.0.2.1/lib/rails/commands/server/server_command.rb:147:in `block in perform'
    from /usr/local/bundle/ruby/2.6.0/gems/railties-6.0.2.1/lib/rails/commands/server/server_command.rb:138:in `tap'
    from /usr/local/bundle/ruby/2.6.0/gems/railties-6.0.2.1/lib/rails/commands/server/server_command.rb:138:in `perform'
    from /usr/local/bundle/ruby/2.6.0/gems/thor-1.0.1/lib/thor/command.rb:27:in `run'
    from /usr/local/bundle/ruby/2.6.0/gems/thor-1.0.1/lib/thor/invocation.rb:127:in `invoke_command'
    from /usr/local/bundle/ruby/2.6.0/gems/thor-1.0.1/lib/thor.rb:392:in `dispatch'
    from /usr/local/bundle/ruby/2.6.0/gems/railties-6.0.2.1/lib/rails/command/base.rb:69:in `perform'
    from /usr/local/bundle/ruby/2.6.0/gems/railties-6.0.2.1/lib/rails/command.rb:46:in `invoke'
    from /usr/local/bundle/ruby/2.6.0/gems/railties-6.0.2.1/lib/rails/commands.rb:18:in `<main>'
    from /usr/local/bundle/ruby/2.6.0/gems/bootsnap-1.4.5/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:22:in `require'
    from /usr/local/bundle/ruby/2.6.0/gems/bootsnap-1.4.5/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:22:in `block in require_with_bootsnap_lfi'
    from /usr/local/bundle/ruby/2.6.0/gems/bootsnap-1.4.5/lib/bootsnap/load_path_cache/loaded_features_index.rb:92:in `register'
    from /usr/local/bundle/ruby/2.6.0/gems/bootsnap-1.4.5/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:21:in `require_with_bootsnap_lfi'
    from /usr/local/bundle/ruby/2.6.0/gems/bootsnap-1.4.5/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:30:in `require'
    from /usr/local/bundle/ruby/2.6.0/gems/activesupport-6.0.2.1/lib/active_support/dependencies.rb:325:in `block in require'
    from /usr/local/bundle/ruby/2.6.0/gems/activesupport-6.0.2.1/lib/active_support/dependencies.rb:291:in `load_dependency'
    from /usr/local/bundle/ruby/2.6.0/gems/activesupport-6.0.2.1/lib/active_support/dependencies.rb:325:in `require'
    from bin/rails:4:in `<main>'
masonhensley commented 4 years ago

Btw - quick and dirty solution seems to be to add the paperclip gem even if it's not being used in your repo.

mrsweaters commented 4 years ago

yeah I encountered this problem as well, worked around it by reluctantly adding paperclip to my Gemfile.

https://github.com/prey/gdpr_rails/issues/43

masonhensley commented 4 years ago

Ahh, thanks @mrsweaters - will close as a dupe. It's linked to #43 .