Mysql + ruby ​​on rails + linux mint = not working

I am using Linux Mint and I have just started learning Ruby on Rails. I have been following Lynda.com tutorials and I am getting hung up on mysql setup. I've tried everything people asked before and I can't seem to find a solution. Let me explain. I installed everything correctly.

matth@MatijaComp ~ $ ruby -v
ruby 2.2.2p95 (2015-04-13 revision 50295) [x86_64-linux]
matth@MatijaComp ~ $ rails -v
Rails 4.2.3
matth@MatijaComp ~ $ mysql --version
mysql  Ver 14.14 Distrib 5.5.44, for debian-linux-gnu (x86_64) using readline 6.3

      

when i start the project with "-d mysql", start my mysql server, run "rake db: create", set up the database.yml file to fill in the password and then just execute "rails server". I hope I've explained all my steps, maybe I forgot something, but I think I've tried everything. Setting a password is not a problem. (without mysql server rails works fine)

[2015-07-25 02:58:46] INFO  WEBrick 1.3.1
[2015-07-25 02:58:46] INFO  ruby 2.2.2 (2015-04-13) [x86_64-linux]
[2015-07-25 02:58:46] INFO  WEBrick::HTTPServer#start: pid=11689 port=3000


Started GET "/" for 127.0.0.1 at 2015-07-25 02:58:48 +0200

Gem::LoadError (Specified 'mysql2' for database adapter, but the gem is not loaded. Add `gem 'mysql2'` to your Gemfile (and ensure its version is at the minimum required by ActiveRecord).):
  activerecord (4.2.3) lib/active_record/connection_adapters/connection_specification.rb:177:in `rescue in spec'
  activerecord (4.2.3) lib/active_record/connection_adapters/connection_specification.rb:174:in `spec'
  activerecord (4.2.3) lib/active_record/connection_handling.rb:50:in `establish_connection'
  activerecord (4.2.3) lib/active_record/railtie.rb:120:in `block (2 levels) in <class:Railtie>'
  activesupport (4.2.3) lib/active_support/lazy_load_hooks.rb:38:in `instance_eval'
  activesupport (4.2.3) lib/active_support/lazy_load_hooks.rb:38:in `execute_hook'
  activesupport (4.2.3) lib/active_support/lazy_load_hooks.rb:45:in `block in run_load_hooks'
  activesupport (4.2.3) lib/active_support/lazy_load_hooks.rb:44:in `each'
  activesupport (4.2.3) lib/active_support/lazy_load_hooks.rb:44:in `run_load_hooks'
  activerecord (4.2.3) lib/active_record/base.rb:315:in `<module:ActiveRecord>'
  activerecord (4.2.3) lib/active_record/base.rb:26:in `<top (required)>'
  activerecord (4.2.3) lib/active_record/migration.rb:383:in `connection'
  activerecord (4.2.3) lib/active_record/migration.rb:370:in `call'
  actionpack (4.2.3) lib/action_dispatch/middleware/callbacks.rb:29:in `block in call'
  activesupport (4.2.3) lib/active_support/callbacks.rb:84:in `run_callbacks'
  actionpack (4.2.3) lib/action_dispatch/middleware/callbacks.rb:27:in `call'
  actionpack (4.2.3) lib/action_dispatch/middleware/reloader.rb:73:in `call'
  actionpack (4.2.3) lib/action_dispatch/middleware/remote_ip.rb:78:in `call'
  actionpack (4.2.3) lib/action_dispatch/middleware/debug_exceptions.rb:17:in `call'
  web-console (2.2.1) lib/web_console/middleware.rb:39:in `call'
  actionpack (4.2.3) lib/action_dispatch/middleware/show_exceptions.rb:30:in `call'
  railties (4.2.3) lib/rails/rack/logger.rb:38:in `call_app'
  railties (4.2.3) lib/rails/rack/logger.rb:20:in `block in call'
  activesupport (4.2.3) lib/active_support/tagged_logging.rb:68:in `block in tagged'
  activesupport (4.2.3) lib/active_support/tagged_logging.rb:26:in `tagged'
  activesupport (4.2.3) lib/active_support/tagged_logging.rb:68:in `tagged'
  railties (4.2.3) lib/rails/rack/logger.rb:20:in `call'
  actionpack (4.2.3) lib/action_dispatch/middleware/request_id.rb:21:in `call'
  rack (1.6.4) lib/rack/methodoverride.rb:22:in `call'
  rack (1.6.4) lib/rack/runtime.rb:18:in `call'
  activesupport (4.2.3) lib/active_support/cache/strategy/local_cache_middleware.rb:28:in `call'
  rack (1.6.4) lib/rack/lock.rb:17:in `call'
  actionpack (4.2.3) lib/action_dispatch/middleware/static.rb:116:in `call'
  rack (1.6.4) lib/rack/sendfile.rb:113:in `call'
  railties (4.2.3) lib/rails/engine.rb:518:in `call'
  railties (4.2.3) lib/rails/application.rb:165:in `call'
  rack (1.6.4) lib/rack/lock.rb:17:in `call'
  rack (1.6.4) lib/rack/content_length.rb:15:in `call'
  rack (1.6.4) lib/rack/handler/webrick.rb:88:in `service'
  /usr/share/rvm/rubies/ruby-2.2.2/lib/ruby/2.2.0/webrick/httpserver.rb:138:in `service'
  /usr/share/rvm/rubies/ruby-2.2.2/lib/ruby/2.2.0/webrick/httpserver.rb:94:in `run'
  /usr/share/rvm/rubies/ruby-2.2.2/lib/ruby/2.2.0/webrick/server.rb:294:in `block in start_thread'

      

It always shows this error no matter what I try. Even if I remove the gems for mysql, comment out the database in the database.yml file, it still doesn't want to work. Thank!

+3


source to share


1 answer


Try running first bundle exec rails s

and see if it gives a different result. If it complains that you are not running the package, run it first bundle install

. A Gem::LoadError

usually means a problem with your Gemfile, and sometimes - for example, if you installed Ruby via a system package manager or installer - the binary rails

will be linked to your system gems, not your projects.The c prefix commands bundle exec

will ensure they run in the context of the current Gemfile.



+2


source







All Articles