当前位置: 动力学知识库 > 问答 > 编程问答 >

ruby - Cannot run rails server on windows

问题描述:

I’m working on getting my first rails application, but for whatever reason, when I run the command $rails server, my terminal throws back this error:

C:\Sites\blog>rails server

=> 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

C:/RailsInstaller/Ruby1.9.3/lib/ruby/gems/1.9.1/gems/bundler-1.3.4/lib/bundler/r

ubygems_integration.rb:214:in `block in replace_gem': Please install the mysql2

adapter: `gem install activerecord-mysql2-adapter` (mysql2 is not part of the bu

ndle. Add it to Gemfile.) (LoadError)

from C:/RailsInstaller/Ruby1.9.3/lib/ruby/gems/1.9.1/gems/activerecord-3

.2.13/lib/active_record/connection_adapters/mysql2_adapter.rb:3:in `<top (requir

ed)>'

from C:/RailsInstaller/Ruby1.9.3/lib/ruby/gems/1.9.1/gems/activesupport-

3.2.13/lib/active_support/dependencies.rb:251:in `require'

from C:/RailsInstaller/Ruby1.9.3/lib/ruby/gems/1.9.1/gems/activesupport-

3.2.13/lib/active_support/dependencies.rb:251:in `block in require'

from C:/RailsInstaller/Ruby1.9.3/lib/ruby/gems/1.9.1/gems/activesupport-

3.2.13/lib/active_support/dependencies.rb:236:in `load_dependency'

from C:/RailsInstaller/Ruby1.9.3/lib/ruby/gems/1.9.1/gems/activesupport-

3.2.13/lib/active_support/dependencies.rb:251:in `require'

from C:/RailsInstaller/Ruby1.9.3/lib/ruby/gems/1.9.1/gems/activerecord-3

.2.13/lib/active_record/connection_adapters/abstract/connection_specification.rb

:50:in `resolve_hash_connection'

from C:/RailsInstaller/Ruby1.9.3/lib/ruby/gems/1.9.1/gems/activerecord-3

.2.13/lib/active_record/connection_adapters/abstract/connection_specification.rb

:41:in `resolve_string_connection'

from C:/RailsInstaller/Ruby1.9.3/lib/ruby/gems/1.9.1/gems/activerecord-3

.2.13/lib/active_record/connection_adapters/abstract/connection_specification.rb

:25:in `spec'

from C:/RailsInstaller/Ruby1.9.3/lib/ruby/gems/1.9.1/gems/activerecord-3

.2.13/lib/active_record/connection_adapters/abstract/connection_specification.rb

:130:in `establish_connection'

from C:/RailsInstaller/Ruby1.9.3/lib/ruby/gems/1.9.1/gems/activerecord-3

.2.13/lib/active_record/railtie.rb:82:in `block (2 levels) in <class:Railtie>'

from C:/RailsInstaller/Ruby1.9.3/lib/ruby/gems/1.9.1/gems/activesupport-

3.2.13/lib/active_support/lazy_load_hooks.rb:36:in `instance_eval'

from C:/RailsInstaller/Ruby1.9.3/lib/ruby/gems/1.9.1/gems/activesupport-

3.2.13/lib/active_support/lazy_load_hooks.rb:36:in `execute_hook'

from C:/RailsInstaller/Ruby1.9.3/lib/ruby/gems/1.9.1/gems/activesupport-

3.2.13/lib/active_support/lazy_load_hooks.rb:43:in `block in run_load_hooks'

from C:/RailsInstaller/Ruby1.9.3/lib/ruby/gems/1.9.1/gems/activesupport-

3.2.13/lib/active_support/lazy_load_hooks.rb:42:in `each'

from C:/RailsInstaller/Ruby1.9.3/lib/ruby/gems/1.9.1/gems/activesupport-

3.2.13/lib/active_support/lazy_load_hooks.rb:42:in `run_load_hooks'

from C:/RailsInstaller/Ruby1.9.3/lib/ruby/gems/1.9.1/gems/activerecord-3

.2.13/lib/active_record/base.rb:720:in `<top (required)>'

from C:/RailsInstaller/Ruby1.9.3/lib/ruby/gems/1.9.1/gems/activerecord-3

.2.13/lib/active_record/railtie.rb:88:in `block in <class:Railtie>'

from C:/RailsInstaller/Ruby1.9.3/lib/ruby/gems/1.9.1/gems/railties-3.2.1

3/lib/rails/initializable.rb:30:in `instance_exec'

from C:/RailsInstaller/Ruby1.9.3/lib/ruby/gems/1.9.1/gems/railties-3.2.1

3/lib/rails/initializable.rb:30:in `run'

from C:/RailsInstaller/Ruby1.9.3/lib/ruby/gems/1.9.1/gems/railties-3.2.1

3/lib/rails/initializable.rb:55:in `block in run_initializers'

from C:/RailsInstaller/Ruby1.9.3/lib/ruby/gems/1.9.1/gems/railties-3.2.1

3/lib/rails/initializable.rb:54:in `each'

from C:/RailsInstaller/Ruby1.9.3/lib/ruby/gems/1.9.1/gems/railties-3.2.1

3/lib/rails/initializable.rb:54:in `run_initializers'

from C:/RailsInstaller/Ruby1.9.3/lib/ruby/gems/1.9.1/gems/railties-3.2.1

3/lib/rails/application.rb:136:in `initialize!'

from C:/RailsInstaller/Ruby1.9.3/lib/ruby/gems/1.9.1/gems/railties-3.2.1

3/lib/rails/railtie/configurable.rb:30:in `method_missing'

from C:/Sites/blog/config/environment.rb:5:in `<top (required)>'

from C:/Sites/blog/config.ru:3:in `require'

from C:/Sites/blog/config.ru:3:in `block in <main>'

from C:/RailsInstaller/Ruby1.9.3/lib/ruby/gems/1.9.1/gems/rack-1.4.5/lib

/rack/builder.rb:51:in `instance_eval'

from C:/RailsInstaller/Ruby1.9.3/lib/ruby/gems/1.9.1/gems/rack-1.4.5/lib

/rack/builder.rb:51:in `initialize'

from C:/Sites/blog/config.ru:in `new'

from C:/Sites/blog/config.ru:in `<main>'

from C:/RailsInstaller/Ruby1.9.3/lib/ruby/gems/1.9.1/gems/rack-1.4.5/lib

/rack/builder.rb:40:in `eval'

from C:/RailsInstaller/Ruby1.9.3/lib/ruby/gems/1.9.1/gems/rack-1.4.5/lib

/rack/builder.rb:40:in `parse_file'

from C:/RailsInstaller/Ruby1.9.3/lib/ruby/gems/1.9.1/gems/rack-1.4.5/lib

/rack/server.rb:200:in `app'

from C:/RailsInstaller/Ruby1.9.3/lib/ruby/gems/1.9.1/gems/railties-3.2.1

3/lib/rails/commands/server.rb:46:in `app'

from C:/RailsInstaller/Ruby1.9.3/lib/ruby/gems/1.9.1/gems/rack-1.4.5/lib

/rack/server.rb:304:in `wrapped_app'

from C:/RailsInstaller/Ruby1.9.3/lib/ruby/gems/1.9.1/gems/rack-1.4.5/lib

/rack/server.rb:254:in `start'

from C:/RailsInstaller/Ruby1.9.3/lib/ruby/gems/1.9.1/gems/railties-3.2.1

3/lib/rails/commands/server.rb:70:in `start'

from C:/RailsInstaller/Ruby1.9.3/lib/ruby/gems/1.9.1/gems/railties-3.2.1

3/lib/rails/commands.rb:55:in `block in <top (required)>'

from C:/RailsInstaller/Ruby1.9.3/lib/ruby/gems/1.9.1/gems/railties-3.2.1

3/lib/rails/commands.rb:50:in `tap'

from C:/RailsInstaller/Ruby1.9.3/lib/ruby/gems/1.9.1/gems/railties-3.2.1

3/lib/rails/commands.rb:50:in `<top (required)>'

from script/rails:6:in `require'

from script/rails:6:in `<main>'

How can I solve the problem?

My Ruby version: ruby 1.9.3p392 (2013-02-22) [i386-mingw32]

Rails version: 3.2.13

gem --version: 1.8.24

网友答案:

Ok, let's see what is written in the output.

mysql2 is not part of the bundle. Add it to Gemfile.

I think it means that mysql2 is not part of the bundle, and you should add it to Gemfile in order to fix this error.

Open Gemfile, add gem 'mysql2' to it, run bundle install, rake db:create && rake db:migrate, and then bundle exec rails server.

分享给朋友:
您可能感兴趣的文章:
随机阅读: