Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Error when trying to install devise in Ruby on Rails 7.0.0

I'm trying to install devise in the rails version I get the error of the latest version of devise

I have tried with other devise versions but it is update it to the latest,

this is the error:

/usr/local/bundle/gems/devise-4.8.0/lib/devise.rb:321:in `ref': undefined method `reference' for ActiveSupport::Dependencies:Module (NoMethodError)
web_1  |    from /usr/local/bundle/gems/devise-4.8.0/lib/devise.rb:340:in `mailer='
web_1  |    from /usr/local/bundle/gems/devise-4.8.0/lib/devise.rb:342:in `<module:Devise>'
web_1  |    from /usr/local/bundle/gems/devise-4.8.0/lib/devise.rb:11:in `<main>'
web_1  |    from /usr/local/bundle/gems/bootsnap-1.8.1/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:23:in `require'
web_1  |    from /usr/local/bundle/gems/bootsnap-1.8.1/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:23:in `block in require_with_bootsnap_lfi'
web_1  |    from /usr/local/bundle/gems/bootsnap-1.8.1/lib/bootsnap/load_path_cache/loaded_features_index.rb:92:in `register'
web_1  |    from /usr/local/bundle/gems/bootsnap-1.8.1/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:22:in `require_with_bootsnap_lfi'
web_1  |    from /usr/local/bundle/gems/bootsnap-1.8.1/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:31:in `require'
web_1  |    from /usr/local/bundle/gems/zeitwerk-2.5.0.beta3/lib/zeitwerk/kernel.rb:35:in `require'
web_1  |    from /usr/local/lib/ruby/3.0.0/bundler/runtime.rb:66:in `block (2 levels) in require'
web_1  |    from /usr/local/lib/ruby/3.0.0/bundler/runtime.rb:61:in `each'
web_1  |    from /usr/local/lib/ruby/3.0.0/bundler/runtime.rb:61:in `block in require'
web_1  |    from /usr/local/lib/ruby/3.0.0/bundler/runtime.rb:50:in `each'
web_1  |    from /usr/local/lib/ruby/3.0.0/bundler/runtime.rb:50:in `require'
web_1  |    from /usr/local/lib/ruby/3.0.0/bundler.rb:174:in `require'

if you could help me I'd be grateful

like image 945
Samuel Da Costa Avatar asked Dec 14 '22 06:12

Samuel Da Costa


1 Answers

Source of the Error

The version of Devise you're using calls a method named reference. https://github.com/heartcombo/devise/blob/c82e4cf47b02002b2fd7ca31d441cf1043fc634c/lib/devise.rb#L320-L323

def self.ref(arg)
  ActiveSupport::Dependencies.reference(arg)
  Getter.new(arg)
end

The method existed in Rails 6: https://github.com/rails/rails/blob/6-0-stable/activesupport/lib/active_support/dependencies.rb#L651-L653

It has been removed in Rails 7: https://github.com/rails/rails/blob/main/activesupport/lib/active_support/dependencies.rb

This line from Rails 7.0.0.alpha1 changelog explains.

Private internal classes of ActiveSupport::Dependencies have been deleted, like ActiveSupport::Dependencies::Reference, ActiveSupport::Dependencies::Blamable, and others.

https://github.com/rails/rails/blob/main/activesupport/CHANGELOG.md#rails-700alpha1-september-15-2021

Fix: Upgrade Devise

Device has released a 4.8.1 version that's compatible with Rails 7. Run bundle update devise to upgrade.

like image 127
Jake Worth Avatar answered Feb 02 '23 00:02

Jake Worth