1

在将工作应用程序从 sqlite 切换到 postgres 后,我在 rails 应用程序上使用 postgres。当我运行 rake 时,我得到错误 cannot load such file -- mysql2. 我从来没有在这个应用程序中使用过 mysql。有任何想法吗?

编辑:

我的 gemfile 不包括 mysql 并且数据库适配器是 postgresql

这是堆栈跟踪:

c:/RailsInstaller/Ruby1.9.3/lib/ruby/gems/1.9.1/gems/thinking-sphinx-3.0.1/lib/thinking_sphinx.rb:5:in `require'
c:/RailsInstaller/Ruby1.9.3/lib/ruby/gems/1.9.1/gems/thinking-sphinx-3.0.1/lib/thinking_sphinx.rb:5:in `<top (required)>'
c:/RailsInstaller/Ruby1.9.3/lib/ruby/gems/1.9.1/gems/thinking-sphinx-3.0.1/lib/thinking-sphinx.rb:1:in `require'
c:/RailsInstaller/Ruby1.9.3/lib/ruby/gems/1.9.1/gems/thinking-sphinx-3.0.1/lib/thinking-sphinx.rb:1:in `<top (required)>'
c:/RailsInstaller/Ruby1.9.3/lib/ruby/gems/1.9.1/gems/bundler-1.0.22/lib/bundler/runtime.rb:68:in `require'
c:/RailsInstaller/Ruby1.9.3/lib/ruby/gems/1.9.1/gems/bundler-1.0.22/lib/bundler/runtime.rb:68:in `block (2 levels) in require'
c:/RailsInstaller/Ruby1.9.3/lib/ruby/gems/1.9.1/gems/bundler-1.0.22/lib/bundler/runtime.rb:66:in `each'
c:/RailsInstaller/Ruby1.9.3/lib/ruby/gems/1.9.1/gems/bundler-1.0.22/lib/bundler/runtime.rb:66:in `block in require'
c:/RailsInstaller/Ruby1.9.3/lib/ruby/gems/1.9.1/gems/bundler-1.0.22/lib/bundler/runtime.rb:55:in `each'
c:/RailsInstaller/Ruby1.9.3/lib/ruby/gems/1.9.1/gems/bundler-1.0.22/lib/bundler/runtime.rb:55:in `require'
c:/RailsInstaller/Ruby1.9.3/lib/ruby/gems/1.9.1/gems/bundler-1.0.22/lib/bundler.rb:122:in `require'
C:/Users/Rotimi/My Documents/Aptana Studio 3 Workspace/Book_Search/book_search/config/application.rb:13:in `<top (required)>'
c:/RailsInstaller/Ruby1.9.3/lib/ruby/site_ruby/1.9.1/rubygems/custom_require.rb:36:in `require'
c:/RailsInstaller/Ruby1.9.3/lib/ruby/site_ruby/1.9.1/rubygems/custom_require.rb:36:in `require'
C:/Users/Rotimi/My Documents/Aptana Studio 3 Workspace/Book_Search/book_search/Rakefile:5:in `<top (required)>'
c:/RailsInstaller/Ruby1.9.3/lib/ruby/gems/1.9.1/gems/rake-10.0.3/lib/rake/rake_module.rb:25:in `load'
c:/RailsInstaller/Ruby1.9.3/lib/ruby/gems/1.9.1/gems/rake-10.0.3/lib/rake/rake_module.rb:25:in `load_rakefile'
c:/RailsInstaller/Ruby1.9.3/lib/ruby/gems/1.9.1/gems/rake-10.0.3/lib/rake/application.rb:583:in `raw_load_rakefile'
c:/RailsInstaller/Ruby1.9.3/lib/ruby/gems/1.9.1/gems/rake-10.0.3/lib/rake/application.rb:89:in `block in load_rakefile'
c:/RailsInstaller/Ruby1.9.3/lib/ruby/gems/1.9.1/gems/rake-10.0.3/lib/rake/application.rb:160:in `standard_exception_handling'
c:/RailsInstaller/Ruby1.9.3/lib/ruby/gems/1.9.1/gems/rake-10.0.3/lib/rake/application.rb:88:in `load_rakefile'
c:/RailsInstaller/Ruby1.9.3/lib/ruby/gems/1.9.1/gems/rake-10.0.3/lib/rake/application.rb:72:in `block in run'
c:/RailsInstaller/Ruby1.9.3/lib/ruby/gems/1.9.1/gems/rake-10.0.3/lib/rake/application.rb:160:in `standard_exception_handling'
c:/RailsInstaller/Ruby1.9.3/lib/ruby/gems/1.9.1/gems/rake-10.0.3/lib/rake/application.rb:70:in `run'
c:/RailsInstaller/Ruby1.9.3/lib/ruby/gems/1.9.1/gems/rake-10.0.3/bin/rake:33:in `<top (required)>'
c:/RailsInstaller/Ruby1.9.3/bin/rake:19:in `load'
c:/RailsInstaller/Ruby1.9.3/bin/rake:19:in `<main>'
4

4 回答 4

3

我认为您的问题与思考狮身人面像有关。我假设您已经使用以下选项构建了它:

./configure --prefix=/usr/local --with-pgsql --without-mysql

Also, note that mysql2 is a requirement for thinking-sphinx. See here:

https://github.com/pat/thinking-sphinx

in particular under installation:

It’s a gem, so install it like you would any other gem. You will also need to specify the Mysql2 gem as well (this is not an inbuilt dependency because JRuby, when supported, will need something different):

gem 'mysql2', '0.3.12b4' gem 'thinking-sphinx', '3.0.0' The mysql2 gem is required for connecting to Sphinx, so please include it even when you’re using PostgreSQL for your database.

于 2013-02-17T19:06:13.537 回答
0

从 Gemfile 中删除 mysql2。尝试获取完整的堆栈跟踪,以便查看谁需要 mysql2。在此处发布堆栈跟踪。在 database.yml 中指定 postgres 作为您的适配器。

于 2013-02-17T17:51:46.727 回答
0

如果您使用捆绑器或从 environment.rb 中删除 gem mysql2,请从 gemfile 中删除

于 2013-02-17T17:54:55.837 回答
0

Remember to include gem 'mysql2' BEFORE 'flying-sphinx' and 'thinking-sphinx' gems

于 2016-09-15T08:05:40.187 回答