mysql2 0.4.0 ruby gem require error

时光总嘲笑我的痴心妄想 提交于 2019-12-11 03:48:56

问题


I installed mysql2 gem using command: gem install mysql2

Done installing documentation for mysql2 after 0 seconds
1 gem installed

But when I do require 'mysql2', I get:

LoadError: cannot load such file -- mysql2/mysql2

Even though the gem installed successfully, gem list mysql2

*** LOCAL GEMS ***

mysql2 (0.4.0)

I am using MacOSX with ruby 2.1.5p273

Any suggestions as to where should I be looking ?


回答1:


Are you sure you have quoted gem name like this require 'mysql2'? Please, show your script.

UPDATE: Looks like a bug in mysql2-0.4.0 version.

If you don't need exactly this version (I doubt so), just rollback to previous latest stable release in 0.3.x branch:

ruby-2.1.5 in ~/projects › gem install mysql2 -v '~> 0.3.0'
Fetching: mysql2-0.3.20.gem (100%)
Building native extensions.  This could take a while...
Successfully installed mysql2-0.3.20
1 gem installed
ruby-2.1.5 in ~/projects › irb
>> require 'mysql2'
=> true
>> 



回答2:


Try using platform -

gem install mysql2 --platform=ruby


来源:https://stackoverflow.com/questions/32534879/mysql2-0-4-0-ruby-gem-require-error

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!