简体   繁体   English

$ rake db:创建rake aborted! 无法加载这样的文件 - mysql2

[英]$ rake db:create rake aborted! cannot load such file — mysql2

I am using postgres on a rails app after switching the working app from sqlite to postgres. 我将工作应用程序从sqlite切换到postgres后,我在rails应用程序上使用postgres。 When I run rake I get the error cannot load such file -- mysql2. 当我运行rake时我得到错误无法加载这样的文件 - mysql2。 I have never used mysql for this app. 我从来没有在这个应用程序中使用mysql。 Any ideas? 有任何想法吗?

EDIT: 编辑:

My gemfile does not include mysql and the database adapter is postgresql 我的gemfile不包含mysql,数据库适配器是postgresql

This is the stack trace: 这是堆栈跟踪:

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

I think your issue is with thinking-sphinx. 我认为你的问题在于思考 - 狮身人面像。 I assume you've built it with the following options: 我假设您使用以下选项构建它:

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

Also, note that mysql2 is a requirement for thinking-sphinx. 另外,请注意mysql2是思考sphinx的必要条件。 See here: 看这里:

https://github.com/pat/thinking-sphinx 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): 您还需要指定Mysql2 gem(这不是内置依赖项,因为JRuby,如果支持,将需要不同的东西):

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. gem'mysql2','0.3.12b4'gem'tharning-sphinx','3.0.0'连接到Sphinx需要mysql2 gem,所以即使你在数据库中使用PostgreSQL也请包含它。

Remove mysql2 from Gemfile. 从Gemfile中删除mysql2。 Try to get a full stack trace so you can see who is requiring mysql2. 尝试获得完整的堆栈跟踪,以便您可以看到谁需要mysql2。 Post the stack trace here. 在此处发布堆栈跟踪。 Specify postgres as your adapter in database.yml. 在database.yml中将postgres指定为适配器。

如果您使用的是bundler,请从gemfile中删除gem mysql2,或者从environments.rb中删除

记得在'flying-sphinx'和'thinking-sphinx'宝石中加入宝石'mysql2'

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM