1

I am getting this error while creating a migration. I'm using MySQL as the database, with rails 6.0.3.2 and ruby 2.6.6

the full error is

Traceback (most recent call last):
        51: from bin/rails:4:in `<main>'
        50: from bin/rails:4:in `require'
        49: from C:/Ruby26-x64/lib/ruby/gems/2.6.0/gems/railties-6.0.3.2/lib/rails/commands.rb:18:in `<top (required)>'
        48: from C:/Ruby26-x64/lib/ruby/gems/2.6.0/gems/railties-6.0.3.2/lib/rails/command.rb:46:in `invoke'
        47: from C:/Ruby26-x64/lib/ruby/gems/2.6.0/gems/railties-6.0.3.2/lib/rails/command/base.rb:69:in `perform'
        46: from C:/Ruby26-x64/lib/ruby/gems/2.6.0/gems/thor-1.0.1/lib/thor.rb:392:in `dispatch'
        45: from C:/Ruby26-x64/lib/ruby/gems/2.6.0/gems/thor-1.0.1/lib/thor/invocation.rb:127:in `invoke_command'
        44: from C:/Ruby26-x64/lib/ruby/gems/2.6.0/gems/thor-1.0.1/lib/thor/command.rb:27:in `run'
        43: from C:/Ruby26-x64/lib/ruby/gems/2.6.0/gems/railties-6.0.3.2/lib/rails/commands/generate/generate_command.rb:21:in `perform'
        42: from C:/Ruby26-x64/lib/ruby/gems/2.6.0/gems/railties-6.0.3.2/lib/rails/command/actions.rb:15:in `require_application_and_environment!'
        41: from C:/Ruby26-x64/lib/ruby/gems/2.6.0/gems/railties-6.0.3.2/lib/rails/command/actions.rb:28:in `require_environment!'
        40: from C:/Ruby26-x64/lib/ruby/gems/2.6.0/gems/railties-6.0.3.2/lib/rails/application.rb:339:in `require_environment!'
        39: from C:/Ruby26-x64/lib/ruby/gems/2.6.0/gems/activesupport-6.0.3.2/lib/active_support/dependencies.rb:324:in `require'
        38: from C:/Ruby26-x64/lib/ruby/gems/2.6.0/gems/activesupport-6.0.3.2/lib/active_support/dependencies.rb:291:in `load_dependency'
        37: from C:/Ruby26-x64/lib/ruby/gems/2.6.0/gems/activesupport-6.0.3.2/lib/active_support/dependencies.rb:324:in `block in require'
        36: from C:/Ruby26-x64/lib/ruby/gems/2.6.0/gems/zeitwerk-2.4.0/lib/zeitwerk/kernel.rb:34:in `require'
        35: from C:/Ruby26-x64/lib/ruby/gems/2.6.0/gems/zeitwerk-2.4.0/lib/zeitwerk/kernel.rb:34:in `require'
        34: from C:/Users/Ritvik/Desktop/railsProjs/bkpk/config/environment.rb:5:in `<top (required)>'
        33: from C:/Ruby26-x64/lib/ruby/gems/2.6.0/gems/railties-6.0.3.2/lib/rails/application.rb:363:in `initialize!'
        32: from C:/Ruby26-x64/lib/ruby/gems/2.6.0/gems/railties-6.0.3.2/lib/rails/initializable.rb:60:in `run_initializers'
        31: from C:/Ruby26-x64/lib/ruby/2.6.0/tsort.rb:205:in `tsort_each'
        30: from C:/Ruby26-x64/lib/ruby/2.6.0/tsort.rb:226:in `tsort_each'
        29: from C:/Ruby26-x64/lib/ruby/2.6.0/tsort.rb:347:in `each_strongly_connected_component'
        28: from C:/Ruby26-x64/lib/ruby/2.6.0/tsort.rb:347:in `call'
        27: from C:/Ruby26-x64/lib/ruby/2.6.0/tsort.rb:347:in `each'
        26: from C:/Ruby26-x64/lib/ruby/2.6.0/tsort.rb:349:in `block in each_strongly_connected_component'
        25: from C:/Ruby26-x64/lib/ruby/2.6.0/tsort.rb:431:in `each_strongly_connected_component_from'
        24: from C:/Ruby26-x64/lib/ruby/2.6.0/tsort.rb:350:in `block (2 levels) in each_strongly_connected_component'
        23: from C:/Ruby26-x64/lib/ruby/2.6.0/tsort.rb:228:in `block in tsort_each'
        22: from C:/Ruby26-x64/lib/ruby/gems/2.6.0/gems/railties-6.0.3.2/lib/rails/initializable.rb:61:in `block in run_initializers'
        21: from C:/Ruby26-x64/lib/ruby/gems/2.6.0/gems/railties-6.0.3.2/lib/rails/initializable.rb:32:in `run'
        20: from C:/Ruby26-x64/lib/ruby/gems/2.6.0/gems/railties-6.0.3.2/lib/rails/initializable.rb:32:in `instance_exec'
        19: from C:/Ruby26-x64/lib/ruby/gems/2.6.0/gems/foreigner-1.7.4/lib/foreigner/railtie.rb:4:in `block in <class:Railtie>'
        18: from C:/Ruby26-x64/lib/ruby/gems/2.6.0/gems/activesupport-6.0.3.2/lib/active_support/lazy_load_hooks.rb:42:in `on_load'
        17: from C:/Ruby26-x64/lib/ruby/gems/2.6.0/gems/activesupport-6.0.3.2/lib/active_support/lazy_load_hooks.rb:42:in `each'
        16: from C:/Ruby26-x64/lib/ruby/gems/2.6.0/gems/activesupport-6.0.3.2/lib/active_support/lazy_load_hooks.rb:43:in `block in on_load'
        15: from C:/Ruby26-x64/lib/ruby/gems/2.6.0/gems/activesupport-6.0.3.2/lib/active_support/lazy_load_hooks.rb:66:in `execute_hook'
        14: from C:/Ruby26-x64/lib/ruby/gems/2.6.0/gems/activesupport-6.0.3.2/lib/active_support/lazy_load_hooks.rb:61:in `with_execution_control'
        13: from C:/Ruby26-x64/lib/ruby/gems/2.6.0/gems/activesupport-6.0.3.2/lib/active_support/lazy_load_hooks.rb:71:in `block in execute_hook'
        12: from C:/Ruby26-x64/lib/ruby/gems/2.6.0/gems/activesupport-6.0.3.2/lib/active_support/lazy_load_hooks.rb:71:in `class_eval'
        11: from C:/Ruby26-x64/lib/ruby/gems/2.6.0/gems/foreigner-1.7.4/lib/foreigner/railtie.rb:5:in `block (2 levels) in <class:Railtie>'
        10: from C:/Ruby26-x64/lib/ruby/gems/2.6.0/gems/foreigner-1.7.4/lib/foreigner/loader.rb:3:in `load'
         9: from C:/Ruby26-x64/lib/ruby/gems/2.6.0/gems/foreigner-1.7.4/lib/foreigner/loader.rb:3:in `module_eval'
         8: from C:/Ruby26-x64/lib/ruby/gems/2.6.0/gems/foreigner-1.7.4/lib/foreigner/loader.rb:5:in `block in load'
         7: from C:/Ruby26-x64/lib/ruby/gems/2.6.0/gems/foreigner-1.7.4/lib/foreigner/loader.rb:5:in `include'
         6: from C:/Ruby26-x64/lib/ruby/gems/2.6.0/gems/foreigner-1.7.4/lib/foreigner/connection_adapters/abstract/schema_definitions.rb:5:in `included'
         5: from C:/Ruby26-x64/lib/ruby/gems/2.6.0/gems/foreigner-1.7.4/lib/foreigner/connection_adapters/abstract/schema_definitions.rb:5:in `class_eval'
         4: from C:/Ruby26-x64/lib/ruby/gems/2.6.0/gems/foreigner-1.7.4/lib/foreigner/connection_adapters/abstract/schema_definitions.rb:6:in `block in included'
         3: from C:/Ruby26-x64/lib/ruby/gems/2.6.0/gems/foreigner-1.7.4/lib/foreigner/connection_adapters/abstract/schema_definitions.rb:6:in `include'
         2: from C:/Ruby26-x64/lib/ruby/gems/2.6.0/gems/activesupport-6.0.3.2/lib/active_support/concern.rb:122:in `append_features'
         1: from C:/Ruby26-x64/lib/ruby/gems/2.6.0/gems/activesupport-6.0.3.2/lib/active_support/concern.rb:122:in `class_eval'
C:/Ruby26-x64/lib/ruby/gems/2.6.0/gems/foreigner-1.7.4/lib/foreigner/connection_adapters/abstract/table.rb:7:in `block in <module:Table>': undefined method `alias_method_chain' for ActiveRecord::ConnectionAdapters::Table:Class (NoMethodError)
Did you mean?  alias_method

I've looked at similar errors on stackoverflow, but haven't found a solution to my problem. The gemfile has gem 'mysql2', '>= 0.4.4'. I tried it on MySQL 0.5.3 but still no luck.

1 Answers1

1

Do you have foreigner gem in your gemfile ? Can you try removing it, doing a bundle install and retry ? According to the documentation of the gem it was rendered obsolete from rails 4.2 as rails added native support for the feature.

If it is not in your gemfile, you need to check what gem depends on it.

AshwinKumarS
  • 1,303
  • 10
  • 13
  • Yes, I had foreigner. I removed it, did `bundle install` and I got the following error: ``` undefined method `alias_method_chain' for ActionDispatch::Request:Class (NoMethodError) Did you mean? alias_method ``` – Ritvik Budhiraja Aug 01 '20 at 08:48
  • Can you tell me the gem that raises it right now ? The error log line that you posted would be preceeded by what gem it originated from. Like in your question on the line where the same error was thrown the start of the line shows that it was from 'foreigner-1.7.4/lib/foreigner/connection_adapters/abstract/table.rb:7' . I think your gemfile contains a bunch of gems which uses deprecated old rails features. – AshwinKumarS Aug 01 '20 at 08:56
  • I also have the same error, if it is the same scenario with me please check https://stackoverflow.com/a/72570686/10279237 – Bushra Mustofa Jun 10 '22 at 07:41