WEBrick rails server won't start
Asked Answered
D

2

1

Could you please recommend a fix?

Remedies I have tried based on other SE questions:

  • run bundle install
  • run gem cleanup
  • run bundle exec rails server
  • run sudo ln -s /usr/local/mysql/lib/libmysqlclient.18.dylib /usr/lib/libmysqlclient.18.dylib
  • remove root password (to match database.yml config file)

Installed:

  • OSX 10.8.3
  • Ruby 2.0.0p0
  • Rails 3.2.13
  • mysql2 gem 0.3.11
  • 'mysql2' in Gemfile
  • Mysql 14.14 5.6.11

To Reproduce:

  • Starting Location: ~/Sites/simple_cms
  • Run "rails server"

I then get the following output:

=> Booting WEBrick
=> Rails 3.2.13 application starting in development on http://0.0.0.0:3000
=> Call with -d to detach
=> Ctrl-C to shutdown server
Exiting
/Users/rh1n0cer0s/.rvm/gems/ruby-2.0.0-p0/gems/mysql2-0.3.11/lib/mysql2/client.rb:44:in `connect': Unknown database 'simple_cms_development' (Mysql2::Error)
    from /Users/rh1n0cer0s/.rvm/gems/ruby-2.0.0-p0/gems/mysql2-0.3.11/lib/mysql2/client.rb:44:in `initialize'
    from /Users/rh1n0cer0s/.rvm/gems/ruby-2.0.0-p0/gems/activerecord-3.2.13/lib/active_record/connection_adapters/mysql2_adapter.rb:16:in `new'
    from /Users/rh1n0cer0s/.rvm/gems/ruby-2.0.0-p0/gems/activerecord-3.2.13/lib/active_record/connection_adapters/mysql2_adapter.rb:16:in `mysql2_connection'
    from /Users/rh1n0cer0s/.rvm/gems/ruby-2.0.0-p0/gems/activerecord-3.2.13/lib/active_record/connection_adapters/abstract/connection_pool.rb:315:in `new_connection'
    from /Users/rh1n0cer0s/.rvm/gems/ruby-2.0.0-p0/gems/activerecord-3.2.13/lib/active_record/connection_adapters/abstract/connection_pool.rb:325:in `checkout_new_connection'
    from /Users/rh1n0cer0s/.rvm/gems/ruby-2.0.0-p0/gems/activerecord-3.2.13/lib/active_record/connection_adapters/abstract/connection_pool.rb:247:in `block (2 levels) in checkout'
    from /Users/rh1n0cer0s/.rvm/gems/ruby-2.0.0-p0/gems/activerecord-3.2.13/lib/active_record/connection_adapters/abstract/connection_pool.rb:242:in `loop'
    from /Users/rh1n0cer0s/.rvm/gems/ruby-2.0.0-p0/gems/activerecord-3.2.13/lib/active_record/connection_adapters/abstract/connection_pool.rb:242:in `block in checkout'
    from /Users/rh1n0cer0s/.rvm/rubies/ruby-2.0.0-p0/lib/ruby/2.0.0/monitor.rb:211:in `mon_synchronize'
    from /Users/rh1n0cer0s/.rvm/gems/ruby-2.0.0-p0/gems/activerecord-3.2.13/lib/active_record/connection_adapters/abstract/connection_pool.rb:239:in `checkout'
    from /Users/rh1n0cer0s/.rvm/gems/ruby-2.0.0-p0/gems/activerecord-3.2.13/lib/active_record/connection_adapters/abstract/connection_pool.rb:102:in `block in connection'
    from /Users/rh1n0cer0s/.rvm/rubies/ruby-2.0.0-p0/lib/ruby/2.0.0/monitor.rb:211:in `mon_synchronize'
    from /Users/rh1n0cer0s/.rvm/gems/ruby-2.0.0-p0/gems/activerecord-3.2.13/lib/active_record/connection_adapters/abstract/connection_pool.rb:101:in `connection'
    from /Users/rh1n0cer0s/.rvm/gems/ruby-2.0.0-p0/gems/activerecord-3.2.13/lib/active_record/connection_adapters/abstract/connection_pool.rb:410:in `retrieve_connection'
    from /Users/rh1n0cer0s/.rvm/gems/ruby-2.0.0-p0/gems/activerecord-3.2.13/lib/active_record/connection_adapters/abstract/connection_specification.rb:171:in `retrieve_connection'
    from /Users/rh1n0cer0s/.rvm/gems/ruby-2.0.0-p0/gems/activerecord-3.2.13/lib/active_record/connection_adapters/abstract/connection_specification.rb:145:in `connection'
    from /Users/rh1n0cer0s/.rvm/gems/ruby-2.0.0-p0/gems/activerecord-3.2.13/lib/active_record/railtie.rb:88:in `block in <class:Railtie>'
    from /Users/rh1n0cer0s/.rvm/gems/ruby-2.0.0-p0/gems/railties-3.2.13/lib/rails/initializable.rb:30:in `instance_exec'
    from /Users/rh1n0cer0s/.rvm/gems/ruby-2.0.0-p0/gems/railties-3.2.13/lib/rails/initializable.rb:30:in `run'
    from /Users/rh1n0cer0s/.rvm/gems/ruby-2.0.0-p0/gems/railties-3.2.13/lib/rails/initializable.rb:55:in `block in run_initializers'
    from /Users/rh1n0cer0s/.rvm/gems/ruby-2.0.0-p0/gems/railties-3.2.13/lib/rails/initializable.rb:54:in `each'
    from /Users/rh1n0cer0s/.rvm/gems/ruby-2.0.0-p0/gems/railties-3.2.13/lib/rails/initializable.rb:54:in `run_initializers'
    from /Users/rh1n0cer0s/.rvm/gems/ruby-2.0.0-p0/gems/railties-3.2.13/lib/rails/application.rb:136:in `initialize!'
    from /Users/rh1n0cer0s/.rvm/gems/ruby-2.0.0-p0/gems/railties-3.2.13/lib/rails/railtie/configurable.rb:30:in `method_missing'
    from /Users/rh1n0cer0s/Sites/simple_cms/config/environment.rb:5:in `<top (required)>'
    from /Users/rh1n0cer0s/Sites/simple_cms/config.ru:3:in `require'
    from /Users/rh1n0cer0s/Sites/simple_cms/config.ru:3:in `block in <main>'
    from /Users/rh1n0cer0s/.rvm/gems/ruby-2.0.0-p0/gems/rack-1.4.5/lib/rack/builder.rb:51:in `instance_eval'
    from /Users/rh1n0cer0s/.rvm/gems/ruby-2.0.0-p0/gems/rack-1.4.5/lib/rack/builder.rb:51:in `initialize'
    from /Users/rh1n0cer0s/Sites/simple_cms/config.ru:in `new'
    from /Users/rh1n0cer0s/Sites/simple_cms/config.ru:in `<main>'
    from /Users/rh1n0cer0s/.rvm/gems/ruby-2.0.0-p0/gems/rack-1.4.5/lib/rack/builder.rb:40:in `eval'
    from /Users/rh1n0cer0s/.rvm/gems/ruby-2.0.0-p0/gems/rack-1.4.5/lib/rack/builder.rb:40:in `parse_file'
    from /Users/rh1n0cer0s/.rvm/gems/ruby-2.0.0-p0/gems/rack-1.4.5/lib/rack/server.rb:200:in `app'
    from /Users/rh1n0cer0s/.rvm/gems/ruby-2.0.0-p0/gems/railties-3.2.13/lib/rails/commands/server.rb:46:in `app'
    from /Users/rh1n0cer0s/.rvm/gems/ruby-2.0.0-p0/gems/rack-1.4.5/lib/rack/server.rb:304:in `wrapped_app'
    from /Users/rh1n0cer0s/.rvm/gems/ruby-2.0.0-p0/gems/rack-1.4.5/lib/rack/server.rb:254:in `start'
    from /Users/rh1n0cer0s/.rvm/gems/ruby-2.0.0-p0/gems/railties-3.2.13/lib/rails/commands/server.rb:70:in `start'
    from /Users/rh1n0cer0s/.rvm/gems/ruby-2.0.0-p0/gems/railties-3.2.13/lib/rails/commands.rb:55:in `block in <top (required)>'
    from /Users/rh1n0cer0s/.rvm/gems/ruby-2.0.0-p0/gems/railties-3.2.13/lib/rails/commands.rb:50:in `tap'
    from /Users/rh1n0cer0s/.rvm/gems/ruby-2.0.0-p0/gems/railties-3.2.13/lib/rails/commands.rb:50:in `<top (required)>'
    from script/rails:6:in `require'
    from script/rails:6:in `<main>'

Here is my gem list:

actionmailer (3.2.13)
actionpack (3.2.13)
activemodel (3.2.13)
activerecord (3.2.13)
activeresource (3.2.13)
activesupport (3.2.13)
arel (3.0.2)
bigdecimal (1.2.0)
builder (3.0.4)
bundler (1.3.5)
coffee-rails (3.2.2)
coffee-script (2.2.0)
coffee-script-source (1.6.2)
erubis (2.7.0)
execjs (1.4.0)
hike (1.2.2)
i18n (0.6.1)
io-console (0.4.2)
journey (1.0.4)
jquery-rails (2.2.1)
json (1.7.7)
mail (2.5.3)
mime-types (1.23)
minitest (4.3.2)
multi_json (1.7.2)
mysql2 (0.3.11)
polyglot (0.3.3)
psych (2.0.0)
rack (1.4.5)
rack-cache (1.2)
rack-ssl (1.3.3)
rack-test (0.6.2)
rails (3.2.13)
railties (3.2.13)
rake (10.0.4, 0.9.6)
rdoc (4.0.0, 3.12.2)
rubygems-bundler (1.1.1)
rvm (1.11.3.7)
sass (3.2.8)
sass-rails (3.2.6)
sprockets (2.2.2)
test-unit (2.0.0.0)
thor (0.18.1)
tilt (1.3.7)
treetop (1.4.12)
tzinfo (0.3.37)
uglifier (2.0.1)

Contents of my database.yml

   development:
      adapter: mysql2
      encoding: utf8
      reconnect: false
      database: simple_cms_development
      pool: 5
      username: root
      password:
      socket: /tmp/mysql.sock

    test:
      adapter: mysql2
      encoding: utf8
      reconnect: false
      database: simple_cms_test
      pool: 5
      username: root
      password:
      socket: /tmp/mysql.sock

    production:
      adapter: mysql2
      encoding: utf8
      reconnect: false
      database: simple_cms_production
      pool: 5
      username: root
      password:
      socket: /tmp/mysql.sock
Dip answered 29/4, 2013 at 16:43 Comment(4)
Is your mysql correctly configured in your OSX? Can you access it with mysql -uroot in your terminal?Crackleware
thanks @Crackleware - I think so...I set it up w/password and can log in using terminal. Could it have something to do with the password not appearing in the database.yml config?Dip
If you have password on root account, then you must specify in database.yml :)Crackleware
Did you run rake db:create?Bargello
H
1

Have you run rake db:create to create your database? After that, rails server should work.

Hooks answered 29/4, 2013 at 19:26 Comment(3)
Hi Nathan - I created the database and linked it to my ruby project (simple_cms)...there's already a database.yml (see above). I'll try your suggestion but before I do is there a reason rake will work instead? Do I need to run it at a certain level of the directory structure?Dip
Nathan and @Sparda thanks...server is running using rake db:create...I installed mysql and created the database without doing this step and thought it was already createdDip
Hey, any chance you could please mark this answer as correct? ThanksHooks
B
0

Try doing this in the terminal and then starting your WEBRick server.

sudo ln -s /usr/local/mysql/lib/libmysqlclient.18.dylib /usr/lib/libmysqlclient.18.dylib

Edit: Got the solution from here, seems like it might be the same situation you're in.

Bedad answered 29/4, 2013 at 16:49 Comment(5)
Thanks @Bedad - Do you know what this does or why it works? sudo can also do harm if not used correctly.Dip
@Dip Yes sudo commands can do harm. But this particular command can't actually do any harm to your computer. Basically the libmysqlclient.18.dylib file seems to be installed in a different location than where it's being looked at (on a lot of these computers). This command is creating a symbolic link where rails is looking for it. A symbolic link is just a small pointer file, so if someone looks at it in the place with the symbolic link, they'll actually see the file from the other location. Think of it like a copy, but instead of actually copying, it's just pointing.Bedad
Thanks for the thoughtful response JoshDip
As he said, it just creates a symbolic link for that sql lib, and it will be fine. :)Crackleware
Thanks Josh and kiddorails - I'm still not able to get the server to run (see new output above)Dip

© 2022 - 2024 — McMap. All rights reserved.