Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Rails 7.1 Incompatibility #1702

Open
boone opened this issue Oct 18, 2023 · 14 comments
Open

Rails 7.1 Incompatibility #1702

boone opened this issue Oct 18, 2023 · 14 comments

Comments

@boone
Copy link

boone commented Oct 18, 2023

I am running a Rails 7.0 app with ActiveGraph 11.4.0 and see a deprecation warning when the app starts:

DEPRECATION WARNING: ActiveSupport::PerThreadRegistry is deprecated and will be removed in Rails 7.1.
Use Module#thread_mattr_accessor instead.

It references the line in application.rb which calls require 'active_graph/railtie'.

It looks like ActiveSupport::PerThreadRegistry is included here: https://github.com/neo4jrb/activegraph/blob/master/lib/active_graph/node/scope.rb#L147. Since that block of code references following ActiveRecord, perhaps whatever the latest ActiveRecord is doing could be used there as well?

Thank you.

@klobuczek
Copy link
Member

@boone could you test activegraph 11.5.0.alpha.1? It has both zeitwerk migration and activesupport 7.1 compatibility.

@boone
Copy link
Author

boone commented Oct 20, 2023

@klobuczek So far all I changed was to set the ActiveGraph gem to the new alpha and updated Gemfile.lock. Trying to start the Rails app I encountered:

/usr/local/bundle/gems/activegraph-11.5.0.alpha.1/lib/active_graph/railtie.rb:45:in `block in <class:Railtie>': uninitialized constant ActiveGraph::Config (NameError)

      ActiveGraph::Config.configuration.merge!(neo4j_config.to_h)

I also noted the neo4j namespaced Rake tasks are unavailable.

Does something else need to change in our app for compatibility with the alpha changes?

Thanks!

@jhulme-ut
Copy link

I just tried it as well.

ActiveGraph version: 11.5.0.alpha.1
Rails version: 7.0.8

And I got this error:

(base) ➜  sh ✗ bundle exec rails c
/Users/jhulme/.rbenv/versions/3.2.0/lib/ruby/gems/3.2.0/gems/io-event-1.3.2/lib/io/event/support.rb:24: warning: IO::Buffer is experimental and both the Ruby and C interface may change in the future!
/Users/jhulme/projects/orders/config/initializers/sidekiq.rb:67: warning: Sidekiq's Delayed Extensions will be removed in Sidekiq 7.0
/Users/jhulme/.rbenv/versions/3.2.0/lib/ruby/gems/3.2.0/gems/activegraph-11.5.0.alpha.1/lib/active_graph/railtie.rb:45:in `block in <class:Railtie>': uninitialized constant ActiveGraph::Config (NameError)

      ActiveGraph::Config.configuration.merge!(neo4j_config.to_h)
                 ^^^^^^^^
Did you mean?  RbConfig
	from /Users/jhulme/.rbenv/versions/3.2.0/lib/ruby/gems/3.2.0/gems/railties-7.0.8/lib/rails/initializable.rb:32:in `instance_exec'
	from /Users/jhulme/.rbenv/versions/3.2.0/lib/ruby/gems/3.2.0/gems/railties-7.0.8/lib/rails/initializable.rb:32:in `run'
	from /Users/jhulme/.rbenv/versions/3.2.0/lib/ruby/gems/3.2.0/gems/railties-7.0.8/lib/rails/initializable.rb:61:in `block in run_initializers'
	from /Users/jhulme/.rbenv/versions/3.2.0/lib/ruby/3.2.0/tsort.rb:228:in `block in tsort_each'
	from /Users/jhulme/.rbenv/versions/3.2.0/lib/ruby/3.2.0/tsort.rb:350:in `block (2 levels) in each_strongly_connected_component'
	from /Users/jhulme/.rbenv/versions/3.2.0/lib/ruby/3.2.0/tsort.rb:431:in `each_strongly_connected_component_from'
	from /Users/jhulme/.rbenv/versions/3.2.0/lib/ruby/3.2.0/tsort.rb:349:in `block in each_strongly_connected_component'
	from /Users/jhulme/.rbenv/versions/3.2.0/lib/ruby/3.2.0/tsort.rb:347:in `each'
	from /Users/jhulme/.rbenv/versions/3.2.0/lib/ruby/3.2.0/tsort.rb:347:in `call'
	from /Users/jhulme/.rbenv/versions/3.2.0/lib/ruby/3.2.0/tsort.rb:347:in `each_strongly_connected_component'
	from /Users/jhulme/.rbenv/versions/3.2.0/lib/ruby/3.2.0/tsort.rb:226:in `tsort_each'
	from /Users/jhulme/.rbenv/versions/3.2.0/lib/ruby/3.2.0/tsort.rb:205:in `tsort_each'
	from /Users/jhulme/.rbenv/versions/3.2.0/lib/ruby/gems/3.2.0/gems/railties-7.0.8/lib/rails/initializable.rb:60:in `run_initializers'
	from /Users/jhulme/.rbenv/versions/3.2.0/lib/ruby/gems/3.2.0/gems/railties-7.0.8/lib/rails/application.rb:372:in `initialize!'
	from /Users/jhulme/.rbenv/versions/3.2.0/lib/ruby/gems/3.2.0/gems/railties-7.0.8/lib/rails/railtie.rb:226:in `public_send'
	from /Users/jhulme/.rbenv/versions/3.2.0/lib/ruby/gems/3.2.0/gems/railties-7.0.8/lib/rails/railtie.rb:226:in `method_missing'
	from /Users/jhulme/projects/orders/config/environment.rb:5:in `<main>'
	from /Users/jhulme/.rbenv/versions/3.2.0/lib/ruby/gems/3.2.0/gems/bootsnap-1.16.0/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:32:in `require'
	from /Users/jhulme/.rbenv/versions/3.2.0/lib/ruby/gems/3.2.0/gems/bootsnap-1.16.0/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:32:in `require'
	from /Users/jhulme/.rbenv/versions/3.2.0/lib/ruby/gems/3.2.0/gems/zeitwerk-2.6.11/lib/zeitwerk/kernel.rb:38:in `require'
	from /Users/jhulme/.rbenv/versions/3.2.0/lib/ruby/gems/3.2.0/gems/railties-7.0.8/lib/rails/application.rb:348:in `require_environment!'
	from /Users/jhulme/.rbenv/versions/3.2.0/lib/ruby/gems/3.2.0/gems/railties-7.0.8/lib/rails/command/actions.rb:28:in `require_environment!'
	from /Users/jhulme/.rbenv/versions/3.2.0/lib/ruby/gems/3.2.0/gems/railties-7.0.8/lib/rails/command/actions.rb:15:in `require_application_and_environment!'
	from /Users/jhulme/.rbenv/versions/3.2.0/lib/ruby/gems/3.2.0/gems/railties-7.0.8/lib/rails/commands/console/console_command.rb:105:in `perform'
	from /Users/jhulme/.rbenv/versions/3.2.0/lib/ruby/gems/3.2.0/gems/thor-1.2.2/lib/thor/command.rb:27:in `run'
	from /Users/jhulme/.rbenv/versions/3.2.0/lib/ruby/gems/3.2.0/gems/thor-1.2.2/lib/thor/invocation.rb:127:in `invoke_command'
	from /Users/jhulme/.rbenv/versions/3.2.0/lib/ruby/gems/3.2.0/gems/thor-1.2.2/lib/thor.rb:392:in `dispatch'
	from /Users/jhulme/.rbenv/versions/3.2.0/lib/ruby/gems/3.2.0/gems/railties-7.0.8/lib/rails/command/base.rb:87:in `perform'
	from /Users/jhulme/.rbenv/versions/3.2.0/lib/ruby/gems/3.2.0/gems/railties-7.0.8/lib/rails/command.rb:48:in `invoke'
	from /Users/jhulme/.rbenv/versions/3.2.0/lib/ruby/gems/3.2.0/gems/railties-7.0.8/lib/rails/commands.rb:18:in `<main>'
	from /Users/jhulme/.rbenv/versions/3.2.0/lib/ruby/gems/3.2.0/gems/bootsnap-1.16.0/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:32:in `require'
	from /Users/jhulme/.rbenv/versions/3.2.0/lib/ruby/gems/3.2.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>'

@jhulme-ut
Copy link

I'm not a zeitwork expert, but I think you still need require 'active_graph' in railtie.rb.
Looking at other gems like action_mailer and active_record they still require themselves in railtie.rb.

When I added require 'active_graph' to railtie.rb the error went away and everything seemed to load

@klobuczek
Copy link
Member

klobuczek commented Dec 29, 2023

@boone @jhulme-ut please have a look at 11.5.0.beta.2. The above issues should be fixed. Let us know if you find any further issues.

@jhulme-ut
Copy link

jhulme-ut commented Jan 3, 2024

Thanks @klobuczek that seems to be working now - tested against neo4j 4.4.26

The only issue I've run into is that a couple of queries are throwing an error:

/usr/src/app/vendor/bundle/ruby/3.2.0/gems/activegraph-11.5.0.beta.2/lib/active_graph/model_schema.rb:103:in `validate_model_schema!':           

Some schema elements were defined by the model (which is no longer supported), but they do not exist in the database.  Run the following to create them if you haven't already: (ActiveGraph::DeprecatedSchemaDefinitionError)

And we weren't getting this error in 11.4.0.
But I think this is just a problem with our database, that is finally being surfaced, not a bug in the gem. I'll see if I can make it go away by generating a migration

update: fixed the issue in our data. And the error is gone now. We just needed to rename the schema migration nodes

MATCH (n:`Neo4j::Migrations::SchemaMigration`) SET n:`ActiveGraph::Migrations::SchemaMigration`

@knirirr
Copy link

knirirr commented Jan 3, 2024

I'm using activegraph-11.5.0.beta.2 with rails-7.1.2 and neo4j-ruby-driver-4.4.5 but still encounter a problem with missing rake tasks. The attached file shows what happens when rake test is run. In my test helper there's the following:

  ActiveGraph::Base.query('MATCH (n) DETACH DELETE n')
  Rails.application.load_tasks
  Rake::Task.define_task(:environment)
  Rake::Task["neo4j:migrate"].invoke
  Rake::Task["graphs:populate_neo4j"].invoke

Commenting out the last two lines "fixes" the issue, and adding require 'active_graph' to the test helper doesn't. Can anyone suggest how I might work around this?

rails_upgrade_fail.txt

@georgkreimer
Copy link

Just read through all your comments here as my attempt to use latest stable releases failed with this error:

cannot load such file -- active_support/per_thread_registry

the following combination doesn't mess with loading:

gem 'activegraph', '11.5.0.beta.2'
gem 'neo4j-ruby-driver', '~> 4.4.5'

@klobuczek
Copy link
Member

klobuczek commented Jan 25, 2024

@georgkreimer the latest stable release is not compatible with the latest rails. We have been hesitant in putting upper limits on the activegraph gem dependencies as that puts more repressibility on our end to frequently retest and re-release. We are stretched thin here. At the moment it is your responsibility to put the upper limits in your Gemfile if you found an incompatibility. It will be mostly on rails gems.
BTW: The second line of your snippet should not be necessary.

@klobuczek
Copy link
Member

Everyone, please retest your cases with https://rubygems.org/gems/activegraph/versions/11.5.0.beta.3

@georgkreimer
Copy link

georgkreimer commented Jan 26, 2024

@klobuczek I appreciate all the work you do!
Actually I was trying to use ActiveGraph together with memgraph, which didn't work for me at the end. I'm now on Neo4j 4.4.19. ActiveGraph works well with that.

Edit: Yes, it works without neo4j-ruby-driver. And ActiveGraph 11.5.0.beta.3 work on latest rails and Neo4j 4.4.19.

@jhulme-ut
Copy link

Everyone, please retest your cases with https://rubygems.org/gems/activegraph/versions/11.5.0.beta.3

Everything seems to be working for me

@jhulme-ut
Copy link

Hi, just wondering if there is an estimate of when 11.5 will be released

@metkat
Copy link

metkat commented Jun 30, 2024

gem 'activegraph', git: 'https://github.com/neo4jrb/activegraph', tag: 'v11.5.0.beta.3'
gem 'neo4j-ruby-driver', '~> 4.4', '>= 4.4.5'

still gives:

/usr/local/bundle/gems/actionpack-7.1.3.4/lib/action_dispatch/railtie.rb:8:in '<module:ActionDispatch>': uninitialized constant Rails::Railtie (NameError)

Updating to v.12 requires v5 of the driver:

gem 'activegraph', git: 'https://github.com/neo4jrb/activegraph', tag: 'v12.0.0.beta.4'
gem 'neo4j-ruby-driver', '~> 4.4', '>= 4.4.5'

resulting in:

    activegraph was resolved to 12.0.0.beta.4, which depends on
      neo4j-ruby-driver (>= 5)

but it looks like all of the neo4j-ruby-driver versions listed at rubygems after 4.4.5 require java, not the ruby-native driver. 🤷‍♂️

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

6 participants