Git Product home page Git Product logo

Comments (13)

justinlittman avatar justinlittman commented on May 28, 2024 1

I encountered a similar issue with v0.6.6 when deploying app to Heroku (but could not reproduce locally).

from action_policy.

gee-forr avatar gee-forr commented on May 28, 2024 1

Updated the title and details to single out eager loading as the setting that triggers this issue.

The cache_classes setting is irrelevant in terms of this bug.

from action_policy.

t27duck avatar t27duck commented on May 28, 2024 1

This is a different error, but I believe is the same issue.

Here's a mostly minimal repo: https://github.com/t27duck/action_policy_eager_load

Check out, bundle install, and rails c should fail.

This is a vanilla rails app (minus action cable) with 0.6.6 installed with a single policy. The policy only has relation_scope in it. In development.rb the only change is setting eager_load to true.

Full stacktrace:

➜  action_policy_eager_load git:(main) rails c
/Users/tdrake/workbench/action_policy_eager_load/app/policies/some_policy.rb:2:in `<class:SomePolicy>': undefined method `relation_scope' for SomePolicy:Class (NoMethodError)
	from /Users/tdrake/workbench/action_policy_eager_load/app/policies/some_policy.rb:1:in `<main>'
	from /Users/tdrake/.rbenv/versions/3.0.4/lib/ruby/gems/3.0.0/gems/bootsnap-1.16.0/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:32:in `require'
	from /Users/tdrake/.rbenv/versions/3.0.4/lib/ruby/gems/3.0.0/gems/bootsnap-1.16.0/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:32:in `require'
	from /Users/tdrake/.rbenv/versions/3.0.4/lib/ruby/gems/3.0.0/gems/zeitwerk-2.6.11/lib/zeitwerk/kernel.rb:30:in `require'
	from /Users/tdrake/.rbenv/versions/3.0.4/lib/ruby/gems/3.0.0/gems/zeitwerk-2.6.11/lib/zeitwerk/loader/helpers.rb:135:in `const_get'
	from /Users/tdrake/.rbenv/versions/3.0.4/lib/ruby/gems/3.0.0/gems/zeitwerk-2.6.11/lib/zeitwerk/loader/helpers.rb:135:in `cget'
	from /Users/tdrake/.rbenv/versions/3.0.4/lib/ruby/gems/3.0.0/gems/zeitwerk-2.6.11/lib/zeitwerk/loader/eager_load.rb:175:in `block in actual_eager_load_dir'
	from /Users/tdrake/.rbenv/versions/3.0.4/lib/ruby/gems/3.0.0/gems/zeitwerk-2.6.11/lib/zeitwerk/loader/helpers.rb:40:in `block in ls'
	from /Users/tdrake/.rbenv/versions/3.0.4/lib/ruby/gems/3.0.0/gems/zeitwerk-2.6.11/lib/zeitwerk/loader/helpers.rb:25:in `each'
	from /Users/tdrake/.rbenv/versions/3.0.4/lib/ruby/gems/3.0.0/gems/zeitwerk-2.6.11/lib/zeitwerk/loader/helpers.rb:25:in `ls'
	from /Users/tdrake/.rbenv/versions/3.0.4/lib/ruby/gems/3.0.0/gems/zeitwerk-2.6.11/lib/zeitwerk/loader/eager_load.rb:170:in `actual_eager_load_dir'
	from /Users/tdrake/.rbenv/versions/3.0.4/lib/ruby/gems/3.0.0/gems/zeitwerk-2.6.11/lib/zeitwerk/loader/eager_load.rb:17:in `block (2 levels) in eager_load'
	from /Users/tdrake/.rbenv/versions/3.0.4/lib/ruby/gems/3.0.0/gems/zeitwerk-2.6.11/lib/zeitwerk/loader/eager_load.rb:16:in `each'
	from /Users/tdrake/.rbenv/versions/3.0.4/lib/ruby/gems/3.0.0/gems/zeitwerk-2.6.11/lib/zeitwerk/loader/eager_load.rb:16:in `block in eager_load'
	from /Users/tdrake/.rbenv/versions/3.0.4/lib/ruby/gems/3.0.0/gems/zeitwerk-2.6.11/lib/zeitwerk/loader/eager_load.rb:10:in `synchronize'
	from /Users/tdrake/.rbenv/versions/3.0.4/lib/ruby/gems/3.0.0/gems/zeitwerk-2.6.11/lib/zeitwerk/loader/eager_load.rb:10:in `eager_load'
	from /Users/tdrake/.rbenv/versions/3.0.4/lib/ruby/gems/3.0.0/gems/zeitwerk-2.6.11/lib/zeitwerk/loader.rb:379:in `block in eager_load_all'
	from /Users/tdrake/.rbenv/versions/3.0.4/lib/ruby/gems/3.0.0/gems/zeitwerk-2.6.11/lib/zeitwerk/loader.rb:377:in `each'
	from /Users/tdrake/.rbenv/versions/3.0.4/lib/ruby/gems/3.0.0/gems/zeitwerk-2.6.11/lib/zeitwerk/loader.rb:377:in `eager_load_all'
	from /Users/tdrake/.rbenv/versions/3.0.4/lib/ruby/gems/3.0.0/gems/railties-7.0.8/lib/rails/application/finisher.rb:74:in `block in <module:Finisher>'
	from /Users/tdrake/.rbenv/versions/3.0.4/lib/ruby/gems/3.0.0/gems/railties-7.0.8/lib/rails/initializable.rb:32:in `instance_exec'
	from /Users/tdrake/.rbenv/versions/3.0.4/lib/ruby/gems/3.0.0/gems/railties-7.0.8/lib/rails/initializable.rb:32:in `run'
	from /Users/tdrake/.rbenv/versions/3.0.4/lib/ruby/gems/3.0.0/gems/railties-7.0.8/lib/rails/initializable.rb:61:in `block in run_initializers'
	from /Users/tdrake/.rbenv/versions/3.0.4/lib/ruby/3.0.0/tsort.rb:228:in `block in tsort_each'
	from /Users/tdrake/.rbenv/versions/3.0.4/lib/ruby/3.0.0/tsort.rb:350:in `block (2 levels) in each_strongly_connected_component'
	from /Users/tdrake/.rbenv/versions/3.0.4/lib/ruby/3.0.0/tsort.rb:431:in `each_strongly_connected_component_from'
	from /Users/tdrake/.rbenv/versions/3.0.4/lib/ruby/3.0.0/tsort.rb:349:in `block in each_strongly_connected_component'
	from /Users/tdrake/.rbenv/versions/3.0.4/lib/ruby/3.0.0/tsort.rb:347:in `each'
	from /Users/tdrake/.rbenv/versions/3.0.4/lib/ruby/3.0.0/tsort.rb:347:in `call'
	from /Users/tdrake/.rbenv/versions/3.0.4/lib/ruby/3.0.0/tsort.rb:347:in `each_strongly_connected_component'
	from /Users/tdrake/.rbenv/versions/3.0.4/lib/ruby/3.0.0/tsort.rb:226:in `tsort_each'
	from /Users/tdrake/.rbenv/versions/3.0.4/lib/ruby/3.0.0/tsort.rb:205:in `tsort_each'
	from /Users/tdrake/.rbenv/versions/3.0.4/lib/ruby/gems/3.0.0/gems/railties-7.0.8/lib/rails/initializable.rb:60:in `run_initializers'
	from /Users/tdrake/.rbenv/versions/3.0.4/lib/ruby/gems/3.0.0/gems/railties-7.0.8/lib/rails/application.rb:372:in `initialize!'
	from /Users/tdrake/workbench/action_policy_eager_load/config/environment.rb:5:in `<main>'
	from /Users/tdrake/.rbenv/versions/3.0.4/lib/ruby/gems/3.0.0/gems/bootsnap-1.16.0/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:32:in `require'
	from /Users/tdrake/.rbenv/versions/3.0.4/lib/ruby/gems/3.0.0/gems/bootsnap-1.16.0/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:32:in `require'
	from /Users/tdrake/.rbenv/versions/3.0.4/lib/ruby/gems/3.0.0/gems/zeitwerk-2.6.11/lib/zeitwerk/kernel.rb:38:in `require'
	from /Users/tdrake/.rbenv/versions/3.0.4/lib/ruby/gems/3.0.0/gems/railties-7.0.8/lib/rails/application.rb:348:in `require_environment!'
	from /Users/tdrake/.rbenv/versions/3.0.4/lib/ruby/gems/3.0.0/gems/railties-7.0.8/lib/rails/command/actions.rb:28:in `require_environment!'
	from /Users/tdrake/.rbenv/versions/3.0.4/lib/ruby/gems/3.0.0/gems/railties-7.0.8/lib/rails/command/actions.rb:15:in `require_application_and_environment!'
	from /Users/tdrake/.rbenv/versions/3.0.4/lib/ruby/gems/3.0.0/gems/railties-7.0.8/lib/rails/commands/console/console_command.rb:105:in `perform'
	from /Users/tdrake/.rbenv/versions/3.0.4/lib/ruby/gems/3.0.0/gems/thor-1.2.2/lib/thor/command.rb:27:in `run'
	from /Users/tdrake/.rbenv/versions/3.0.4/lib/ruby/gems/3.0.0/gems/thor-1.2.2/lib/thor/invocation.rb:127:in `invoke_command'
	from /Users/tdrake/.rbenv/versions/3.0.4/lib/ruby/gems/3.0.0/gems/thor-1.2.2/lib/thor.rb:392:in `dispatch'
	from /Users/tdrake/.rbenv/versions/3.0.4/lib/ruby/gems/3.0.0/gems/railties-7.0.8/lib/rails/command/base.rb:87:in `perform'
	from /Users/tdrake/.rbenv/versions/3.0.4/lib/ruby/gems/3.0.0/gems/railties-7.0.8/lib/rails/command.rb:48:in `invoke'
	from /Users/tdrake/.rbenv/versions/3.0.4/lib/ruby/gems/3.0.0/gems/railties-7.0.8/lib/rails/commands.rb:18:in `<main>'
	from /Users/tdrake/.rbenv/versions/3.0.4/lib/ruby/gems/3.0.0/gems/bootsnap-1.16.0/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:32:in `require'
	from /Users/tdrake/.rbenv/versions/3.0.4/lib/ruby/gems/3.0.0/gems/bootsnap-1.16.0/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:32:in `require'
	from bin/rails:4:in `<main>'

Setting eager_load to false does not invoke this exception.

from action_policy.

t27duck avatar t27duck commented on May 28, 2024 1

Also verified that 0.6.5 does not have this issue.

I have not disected anything, but my guess is this one did it:

2a05318

from action_policy.

t27duck avatar t27duck commented on May 28, 2024 1

Just YOLO-ed a production app deploy that broke with 0.6.6 and pointed it to master. Restarts and runs just fine with this change.

from action_policy.

gee-forr avatar gee-forr commented on May 28, 2024 1

thanks so much @palkan and @t27duck and everyone else. Really appreciate the speedy fix.

@palkan - apologies that I wasn't able to effectively replicate the problem. Thank you again for all these amazing gems. Your work has made a materially positive difference to my team's ability to ship useful code in record time. ❤️

from action_policy.

mdi avatar mdi commented on May 28, 2024

I'm seeing the same issue as well.

from action_policy.

gee-forr avatar gee-forr commented on May 28, 2024

I encountered a similar issue with v0.6.6 when deploying app to Heroku (but could not reproduce locally).

Try setting config/environments/development.rb's config.eager_load to true and see if that reproduces the issue locally for you when trying to start your rails server?

from action_policy.

justinlittman avatar justinlittman commented on May 28, 2024

Hmmm ... I couldn't reproduce with that setting change.

from action_policy.

palkan avatar palkan commented on May 28, 2024

@t27duck Thanks a lot for the reproduction! Checking right now

from action_policy.

palkan avatar palkan commented on May 28, 2024

Fixed in master. I'd appreciate If anyone has a chance to check the fix against the real app. In any case, will publish a new release in the end of the day.

from action_policy.

t27duck avatar t27duck commented on May 28, 2024

Verified master works with the minimal repo.

I switched eager_load to true in dev mode for a production app locally which fails to run rails c on 0.6.6 and switched the gem to master. It appears to boot properly now too.

from action_policy.

palkan avatar palkan commented on May 28, 2024

Thanks!

Released in 0.6.7.

from action_policy.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.