Your Location is: Home > Mysql

Rake aborted! cannot load such file — arel/visitor/mysql

From: Bern View: 1755 Soufiane Neffar 

Question

When I try to run Rake (also with Rails commands) commands I got this error :

Rake aborted! cannot load such file -- arel/visitor/mysql
/config/application.rb:7:in <top (required)>
/Rakefile:4:in 'require_relative'

MySql database works perfectly, and I've added gem 'mysql2' in Gemfile.

Using --trace argument :

rake aborted!
LoadError: cannot load such file -- arel/visitors/mysql
/home/sneffar/.rbenv/versions/2.6.6/lib/ruby/gems/2.6.0/gems/activesupport-6.0.3.1/lib/active_support/dependencies.rb:324:in `require'
/home/sneffar/.rbenv/versions/2.6.6/lib/ruby/gems/2.6.0/gems/activesupport-6.0.3.1/lib/active_support/dependencies.rb:324:in `block in require'
/home/sneffar/.rbenv/versions/2.6.6/lib/ruby/gems/2.6.0/gems/activesupport-6.0.3.1/lib/active_support/dependencies.rb:291:in `load_dependency'
/home/sneffar/.rbenv/versions/2.6.6/lib/ruby/gems/2.6.0/gems/activesupport-6.0.3.1/lib/active_support/dependencies.rb:324:in `require'
/home/sneffar/.rbenv/versions/2.6.6/lib/ruby/gems/2.6.0/gems/activerecord-6.0.3.1/lib/arel/visitors.rb:8:in `<top (required)>'
/home/sneffar/.rbenv/versions/2.6.6/lib/ruby/gems/2.6.0/gems/activesupport-6.0.3.1/lib/active_support/dependencies.rb:324:in `require'
/home/sneffar/.rbenv/versions/2.6.6/lib/ruby/gems/2.6.0/gems/activesupport-6.0.3.1/lib/active_support/dependencies.rb:324:in `block in require'
/home/sneffar/.rbenv/versions/2.6.6/lib/ruby/gems/2.6.0/gems/activesupport-6.0.3.1/lib/active_support/dependencies.rb:291:in `load_dependency'
/home/sneffar/.rbenv/versions/2.6.6/lib/ruby/gems/2.6.0/gems/activesupport-6.0.3.1/lib/active_support/dependencies.rb:324:in `require'
/home/sneffar/.rbenv/versions/2.6.6/lib/ruby/gems/2.6.0/gems/activerecord-6.0.3.1/lib/arel.rb:17:in `<top (required)>'
/home/sneffar/.rbenv/versions/2.6.6/lib/ruby/gems/2.6.0/gems/activesupport-6.0.3.1/lib/active_support/dependencies.rb:324:in `require'
/home/sneffar/.rbenv/versions/2.6.6/lib/ruby/gems/2.6.0/gems/activesupport-6.0.3.1/lib/active_support/dependencies.rb:324:in `block in require'
/home/sneffar/.rbenv/versions/2.6.6/lib/ruby/gems/2.6.0/gems/activesupport-6.0.3.1/lib/active_support/dependencies.rb:291:in `load_dependency'
/home/sneffar/.rbenv/versions/2.6.6/lib/ruby/gems/2.6.0/gems/activesupport-6.0.3.1/lib/active_support/dependencies.rb:324:in `require'
/home/sneffar/.rbenv/versions/2.6.6/lib/ruby/gems/2.6.0/gems/activerecord-6.0.3.1/lib/active_record.rb:29:in `<top (required)>'
/home/sneffar/.rbenv/versions/2.6.6/lib/ruby/gems/2.6.0/gems/activesupport-6.0.3.1/lib/active_support/dependencies.rb:324:in `require'
/home/sneffar/.rbenv/versions/2.6.6/lib/ruby/gems/2.6.0/gems/activesupport-6.0.3.1/lib/active_support/dependencies.rb:324:in `block in require'
/home/sneffar/.rbenv/versions/2.6.6/lib/ruby/gems/2.6.0/gems/activesupport-6.0.3.1/lib/active_support/dependencies.rb:291:in `load_dependency'
/home/sneffar/.rbenv/versions/2.6.6/lib/ruby/gems/2.6.0/gems/activesupport-6.0.3.1/lib/active_support/dependencies.rb:324:in `require'
/home/sneffar/.rbenv/versions/2.6.6/lib/ruby/gems/2.6.0/gems/activerecord-6.0.3.1/lib/active_record/railtie.rb:3:in `<top (required)>'
/home/sneffar/.rbenv/versions/2.6.6/lib/ruby/gems/2.6.0/gems/activesupport-6.0.3.1/lib/active_support/dependencies.rb:324:in `require'
/home/sneffar/.rbenv/versions/2.6.6/lib/ruby/gems/2.6.0/gems/activesupport-6.0.3.1/lib/active_support/dependencies.rb:324:in `block in require'
/home/sneffar/.rbenv/versions/2.6.6/lib/ruby/gems/2.6.0/gems/activesupport-6.0.3.1/lib/active_support/dependencies.rb:291:in `load_dependency'
/home/sneffar/.rbenv/versions/2.6.6/lib/ruby/gems/2.6.0/gems/activesupport-6.0.3.1/lib/active_support/dependencies.rb:324:in `require'
/home/sneffar/working-dir/permission/config/application.rb:7:in `<top (required)>'
/home/sneffar/working-dir/permission/Rakefile:4:in `require_relative'
/home/sneffar/working-dir/permission/Rakefile:4:in `<top (required)>'
/home/sneffar/.rbenv/versions/2.6.6/lib/ruby/gems/2.6.0/gems/rake-13.0.1/lib/rake/rake_module.rb:29:in `load'
/home/sneffar/.rbenv/versions/2.6.6/lib/ruby/gems/2.6.0/gems/rake-13.0.1/lib/rake/rake_module.rb:29:in `load_rakefile'
/home/sneffar/.rbenv/versions/2.6.6/lib/ruby/gems/2.6.0/gems/rake-13.0.1/lib/rake/application.rb:703:in `raw_load_rakefile'
/home/sneffar/.rbenv/versions/2.6.6/lib/ruby/gems/2.6.0/gems/rake-13.0.1/lib/rake/application.rb:104:in `block in load_rakefile'
/home/sneffar/.rbenv/versions/2.6.6/lib/ruby/gems/2.6.0/gems/rake-13.0.1/lib/rake/application.rb:186:in `standard_exception_handling'
/home/sneffar/.rbenv/versions/2.6.6/lib/ruby/gems/2.6.0/gems/rake-13.0.1/lib/rake/application.rb:103:in `load_rakefile'
/home/sneffar/.rbenv/versions/2.6.6/lib/ruby/gems/2.6.0/gems/rake-13.0.1/lib/rake/application.rb:82:in `block in run'
/home/sneffar/.rbenv/versions/2.6.6/lib/ruby/gems/2.6.0/gems/rake-13.0.1/lib/rake/application.rb:186:in `standard_exception_handling'
/home/sneffar/.rbenv/versions/2.6.6/lib/ruby/gems/2.6.0/gems/rake-13.0.1/lib/rake/application.rb:80:in `run'
/home/sneffar/.rbenv/versions/2.6.6/lib/ruby/gems/2.6.0/gems/rake-13.0.1/exe/rake:27:in `<top (required)>'
/home/sneffar/.rbenv/versions/2.6.6/bin/rake:23:in `load'
/home/sneffar/.rbenv/versions/2.6.6/bin/rake:23:in `<main>'

Ruby --version : 2.6.6 Rails --version : 6.0.3.1 Rake --version: 13.0.1

Best answer

I think you should remove arel:

gem uninstall arel

After that run:

bundle install

This should fix problem.

Another answer

I also faced with this and agree with Nezir. I believe that in my case, this happened because of such actions: MySQL 5.7.30 -> MySQL 8.0.20 -> MySQL 5.7.30 The first time I had MySQL 5.7.30 it was fine with bundle exec rake db:create db:structure:load