简体   繁体   English

安装mysql2适配器时出错:请安装mysql2适配器:`gem install activerecord-mysql2-adapter`(无法加载此类文件 - mysql2 / mysql2)

[英]Error installing mysql2 adapter: Please install the mysql2 adapter: `gem install activerecord-mysql2-adapter` (cannot load such file — mysql2/mysql2)

I am getting this error when running Redmine2.3-stable, and subsequently unable to install the mysql2 adapter successfully. 运行Redmine2.3-stable时出现此错误,随后无法成功安装mysql2适配器。

This is the error: 这是错误:

    Please install the mysql2 adapter: `gem install activerecord-mysql2-adapter` (cannot load such file -- mysql2/mysql2)

I'm getting this when running the website, via passenger, and when running rake db:migrate 我在运行网站,通过乘客,以及运行rake db:migrate时得到这个

The adapter is installed: 适配器已安装:

gem list 宝石清单

* LOCAL GEMS * *本地宝石*

actionmailer (3.2.13)
actionpack (3.2.13)
activemodel (3.2.13)
activerecord (3.2.13)
activerecord-mysql2-adapter (0.0.3)
activeresource (3.2.13)
activesupport (3.2.13)
afm (0.2.0)
arel (3.0.2)
Ascii85 (1.0.2)
bigdecimal (1.1.0)
builder (3.0.4, 3.0.0)
bundler (1.3.4)
coderay (1.0.9)
daemon_controller (1.1.2)
daemons (1.1.9)
erubis (2.7.0)
eventmachine (1.0.3)
fastthread (1.0.7)
hashery (2.1.0)
hike (1.2.1)
holidays (1.0.5)
i18n (0.6.1)
icalendar (1.2.3)
io-console (0.3)
journey (1.0.4)
jquery-rails (2.0.3)
json (1.7.7, 1.5.4)
mail (2.5.3)
mime-types (1.21)
minitest (4.7.0, 2.5.1)
multi_json (1.7.2)
mysql2 (0.3.11)
net-ldap (0.3.1)
nokogiri (1.5.9)
open-uri-cached (0.0.5)
passenger (3.0.19)
pdf-reader (1.3.2)
polyglot (0.3.3)
prawn (0.12.0)
rack (1.4.5)
rack-cache (1.2)
rack-openid (1.3.1)
rack-ssl (1.3.3)
rack-test (0.6.2)
rails (3.2.13)
railties (3.2.13)
rake (10.0.4, 0.9.2.2)
rdoc (3.12.2, 3.9.4)
ruby-openid (2.1.8)
ruby-rc4 (0.1.5)
rubygems-update (2.0.3)
sprockets (2.2.2)
thin (1.5.1)
thor (0.17.0)
tilt (1.3.6)
treetop (1.4.12)
ttfunk (1.0.3)
tzinfo (0.3.37)

ruby -v 红宝石-v

ruby 1.9.3p194 (2012-04-20 revision 35410) [x86_64-linux]

gem env 宝石环境

- RUBYGEMS VERSION: 2.0.3
- RUBY VERSION: 1.9.3 (2012-04-20 patchlevel 194) [x86_64-linux]
- INSTALLATION DIRECTORY: /usr/local/lib/ruby/gems/1.9.1
- RUBY EXECUTABLE: /usr/local/bin/ruby
- EXECUTABLE DIRECTORY: /usr/local/bin
- RUBYGEMS PLATFORMS:
  - ruby
  - x86_64-linux
- GEM PATHS:
   - /usr/local/lib/ruby/gems/1.9.1
   - /root/.gem/ruby/1.9.1
- GEM CONFIGURATION:
   - :update_sources => true
   - :verbose => true
   - :backtrace => false
   - :bulk_threshold => 1000
- REMOTE SOURCES:
   - https://rubygems.org/

I tried forcing redmine to rails3.2.2 by editing the Gemfile, per a suggestion here: 根据建议,我尝试通过编辑Gemfile强制redmine到rails3.2.2:

Rails 3.2.2 mysql2 adapter Error Rails 3.2.2 mysql2适配器错误

Notes 笔记

I had to force the gem mysql2 bundle install to work by using the command below ( i was getting errors about errormsg.h). 我不得不使用下面的命令强制gem mysql2 bundle install工作(我收到有关errormsg.h的错误)。

sudo gem install activerecord-mysql2-adapter -- --srcdir=/usr/include/mysql/

Any thoughts? 有什么想法吗?

Include mysql2 gem in your Gemfile and also change adapter in database.yml to mysql2 and then do the bundle install. 在Gemfile中包含mysql2 gem,并将database.yml中的适配器更改为mysql2,然后执行bundle install。 It will solve your problem .. 它会解决你的问题..

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

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