0

Windows 7 で WEBrick を使用して Rails サーバーを起動すると、次のエラーが発生します。

C:/Ruby200-x64/lib/ruby/gems/2.0.0/gems/bundler-1.3.5/lib/bundler/rubygems_integ ration.rb:214:in block in replace_gem': Please install the mysql2 adapter:gem install activerecord-mysql2-adapter` (mysql2 は一部ではありません)バンドルの Gemfile に追加します。) (LoadError)

database.yml に mysql2 としてのアダプターがあることを確認しました。gemfile には mysql2 がリストされています。以下は私のdatabase.ymlファイルとgemファイルです

    development:
      adapter: mysql2
      encoding: utf8
      reconnect: false
      database: elearn3_development
      pool: 5
      username: root
      password: password
      host: 127.0.0.1
      port: 3306

    test:
      adapter: mysql2
      encoding: utf8
      reconnect: false
      database: elearn3_test
      pool: 5
      username: root
      password: passsword
      host: 127.0.0.1
      port: 3306

    production:
      adapter: mysql2
      encoding: utf8
      reconnect: false
      database: elearn3_production
      pool: 5
      username: root
      password: passsword
      host: 127.0.0.1
      port: 3306

Gem ファイル: ソース「https://rubygems.org

gem 'rails', '3.2.13'

# Bundle edge Rails instead:
# gem 'rails', :git => 'git://github.com/rails/rails.git'

gem 'mysql2'


# Gems used only for assets and not required
# in production environments by default.
group :assets do
  gem 'sass-rails',   '~> 3.2.3'
  gem 'coffee-rails', '~> 3.2.1'

# See https://github.com/sstephenson/execjs#readme for more supported runtimes
# gem 'therubyracer', :platforms => :ruby

gem 'uglifier', '>= 1.0.3'
    end

gem 'jquery-rails'

宝石「mysql2」「バージョン番号」を追加するなど、同じ問題を抱えている他のスレッドに投稿されたさまざまなオプションをすべて試しました。問題は解決しません。sql-lite の発行中にも同じ問題が発生します。

あなたの助けに感謝します。前もって感謝します。

編集: bundle install を実行すると、ウィンドウに次のように表示されます。mysql2 が using リストに含まれていないことに注意してください。それは正常ですか?

    Using rake (10.0.4)
Using i18n (0.6.1)
Using multi_json (1.7.2)
Using activesupport (3.2.13)
Using builder (3.0.4)
Using activemodel (3.2.13)
Using erubis (2.7.0)
Using journey (1.0.4)
Using rack (1.4.5)
Using rack-cache (1.2)
Using rack-test (0.6.2)
Using hike (1.2.2)
Using tilt (1.4.0)
Using sprockets (2.2.2)
Using actionpack (3.2.13)
Using mime-types (1.23)
Using polyglot (0.3.3)
Using treetop (1.4.12)
Using mail (2.5.3)
Using actionmailer (3.2.13)
Using arel (3.0.2)
Using tzinfo (0.3.37)
Using activerecord (3.2.13)
Using activeresource (3.2.13)
Using coffee-script-source (1.6.2)
Using execjs (1.4.0)
Using coffee-script (2.2.0)
Using rack-ssl (1.3.3)
Using json (1.7.7)
Using rdoc (3.12.2)
Using thor (0.18.1)
Using railties (3.2.13)
Using coffee-rails (3.2.2)
Using jquery-rails (2.2.1)
Using bundler (1.3.5)
Using rails (3.2.13)
Using sass (3.2.8)
Using sass-rails (3.2.6)
Using uglifier (2.0.1)
Your bundle is complete!
Use `bundle show [gemname]` to see where a bundled gem is installed.

編集http://www.mohanarun.com/how-to-install-mysql-adapter-ruby-gem-in-windows/の指示を試した後、バンドル インストールが mysql を選択していることがわかります。しかし、Railsサーバーを実行すると、次のエラーが発生します。

/* 前にさらに多くのエラーが発生しました */

pport/core_ext/load_error.rb 369 C:/Ruby200-x64/lib/ruby/gems/2.0.0/gems/activesupport-3.2.13/lib/active_su pport/core_ext/name_error.rb 370 C:/Ruby200-x64 /lib/ruby/gems/2.0.0/gems/activesupport-3.2.13/lib/active_support/core_ext/uri.rb 371 C:/Ruby200-x64/lib/ruby/gems/2.0.0/gems/actionpack -3.2.13/lib/action_controller.rb 372 C:/Ruby200-x64/lib/ruby/gems/2.0.0/gems/actionpack-3.2.13/lib/action_view/railtie.rb 373 C:/Ruby200- x64/lib/ruby/gems/2.0.0/gems/actionpack-3.2.13/lib/abstract_controller/railties/routes_helpers.rb 374 C:/Ruby200-x64/lib/ruby/gems/2.0.0/gems/ actionpack-3.2.13/lib/action_controller/railties/paths.rb 375 C:/Ruby200-x64/lib/ruby/gems/2.0.0/gems/actionpack-3.2.13/lib/action_controller/railtie.rb 376 C:/Ruby200-x64/lib/ruby/gems/2.0.0/gems/activerecord-3.2.13/lib/active_rec ord/railtie.rb 377 C:/Ruby200-x64/lib/ruby/gems/2.0.0/gems/actionmailer-3.2.13/lib/action_mailer/version.rb 378 C:/Ruby200-x64/lib/ruby/gems/2.0.0/gems /activesupport-3.2.13/lib/active_support/core_ext/class/delegating_attributes.rb 379 C:/Ruby200-x64/lib/ruby/gems/2.0.0/gems/activesupport-3.2.13/lib/active_support/ core_ext/module/reachable.rb 380 C:/Ruby200-x64/lib/ruby/gems/2.0.0/gems/activesupport-3.2.13/lib/active_support/core_ext/class/subclasses.rb 381 C:/Ruby200 -x64/lib/ruby/gems/2.0.0/gems/activesupport-3.2.13/lib/active_support/core_ext/class.rb 382 C:/Ruby200-x64/lib/ruby/gems/2.0.0/gems /activesupport-3.2.13/lib/active_support/core_ext/array/uniq_by.rb 383 C:/Ruby200-x64/lib/ruby/gems/2.0.0/gems/actionmailer-3.2.13/lib/action_mailer. rb 384 C:/Ruby200-x64/lib/ruby/gems/2.0.0/gems/actionmailer-3.2.13/lib/action_mailer/railtie.rb 385 C:/Ruby200-x64/lib/ruby/gems/2.0.0/gems/activeresource-3.2.13/lib/active_resource/exceptions.rb 386 C:/Ruby200-x64/lib/ruby/gems/2.0.0/gems /activeresource-3.2.13/lib/active_resource/version.rb 387 C:/Ruby200-x64/lib/ruby/gems/2.0.0/gems/activeresource-3.2.13/lib/active_resource.rb 388 C: /Ruby200-x64/lib/ruby/gems/2.0.0/gems/activeresource-3.2.13/lib/active_resource/railtie.rb 389 C:/Ruby200-x64/lib/ruby/gems/2.0.0/gems /railties-3.2.13/lib/rails/test_uni t/railtie.rb 390 C:/Ruby200-x64/lib/ruby/gems/2.0.0/gems/actionpack-3.2.13/lib/sprockets/railtie. rb 391 C:/Ruby200-x64/lib/ruby/gems/2.0.0/gems/railties-3.2.13/lib/rails/all.rb 392 C:/Ruby200-x64/lib/ruby/gems/2.0. 0/gems/activesupport-3.2.13/lib/active_su pport/string_inquirer.rb 393 C:/Ruby200-x64/lib/ruby/gems/2.0.0/gems/mysql2-0.3.11/lib/mysql2/バージョン. r b 394 C:/Ruby200-x64/lib/ruby/gems/2.0.0/gems/mysql2-0.3.11/lib/mysql2/error.rb 395 C:/Ruby200-x64/lib/ruby/gems/2.0.0/gems/ mysql2-0.3.11/lib/mysql2/result.rb

[注] Ruby インタープリターまたは拡張ライブラリーでバグに遭遇した可能性があります。バグ報告は大歓迎です。詳細: バグレポート

このアプリケーションは、異常な方法で終了するようランタイムに要求しました。詳細については、アプリケーションのサポート チームにお問い合わせください。

4

3 に答える 3

0

Gemfile を変更してバンドルをインストールしたら、Rails サーバーを再起動する必要があります。これにより、バンドルの gem がリロードされます。

于 2013-07-31T04:17:31.837 に答える
0

Production でも同様の問題が発生し、以下が問題でした。

  1. Gemfile で sqlite gem を開発用に移動する必要がありました
  2. Gemfile のデプロイメントに mysql2 gem を追加する必要がありました
  3. Gemlock を更新するには bundle install を実行する必要がありました
  4. これらの変更を git にコミットし、リモート git リポジトリを更新する必要がありました。

これらは私のプロダクション設定に非常に固有の手順でしたが、他の人にも役立つことを願っています.

于 2013-08-03T05:10:27.110 に答える