Gem mysql2 出现 incompatible library version 的问题

shisong · 2017年11月27日 · 1674 次阅读

今天搭环境,要求使用 ruby 和 rails 版本分别是:1.9.3@329。我所使用的系统是ubuntu17.04的,本以为很快就搞定了,然而被一个问题卡住一直解决不了。

$ rails s
Ignoring eventmachine-1.2.5 because its extensions are not built.  Try: gem pristine eventmachine --version 1.2.5
Ignoring executable-hooks-1.3.2 because its extensions are not built.  Try: gem pristine executable-hooks --version 1.3.2
Ignoring ffi-1.9.18 because its extensions are not built.  Try: gem pristine ffi --version 1.9.18
Ignoring gem-wrappers-1.4.0 because its extensions are not built.  Try: gem pristine gem-wrappers --version 1.4.0
Ignoring gem-wrappers-1.3.2 because its extensions are not built.  Try: gem pristine gem-wrappers --version 1.3.2
Ignoring json-1.8.6 because its extensions are not built.  Try: gem pristine json --version 1.8.6
Ignoring mysql2-0.3.20 because its extensions are not built.  Try: gem pristine mysql2 --version 0.3.20
Ignoring mysql2-0.3.19 because its extensions are not built.  Try: gem pristine mysql2 --version 0.3.19
/home/shisongsong/.rvm/gems/ruby-2.2.8@329/gems/activesupport-3.2.9/lib/active_support/values/time_zone.rb:270: warning: circular argument reference - now
/home/shisongsong/.rvm/gems/ruby-2.2.8@329/gems/mysql2-0.3.20/lib/mysql2.rb:31:in `require': incompatible library version - /home/shisongsong/.rvm/gems/ruby-2.2.8@329/gems/mysql2-0.3.20/lib/mysql2/mysql2.so (LoadError)
    from /home/shisongsong/.rvm/gems/ruby-2.2.8@329/gems/mysql2-0.3.20/lib/mysql2.rb:31:in `<top (required)>'
    from /usr/lib/ruby/vendor_ruby/bundler/runtime.rb:91:in `require'
    from /usr/lib/ruby/vendor_ruby/bundler/runtime.rb:91:in `block (2 levels) in require'
    from /usr/lib/ruby/vendor_ruby/bundler/runtime.rb:86:in `each'
    from /usr/lib/ruby/vendor_ruby/bundler/runtime.rb:86:in `block in require'
    from /usr/lib/ruby/vendor_ruby/bundler/runtime.rb:75:in `each'
    from /usr/lib/ruby/vendor_ruby/bundler/runtime.rb:75:in `require'
    from /usr/lib/ruby/vendor_ruby/bundler.rb:106:in `require'
    from /home/shisongsong/Workspace/ruby/rails/ep/config/application.rb:8:in `<top (required)>'
    from /home/shisongsong/.rvm/gems/ruby-2.2.8@329/gems/railties-3.2.9/lib/rails/commands.rb:53:in `require'
    from /home/shisongsong/.rvm/gems/ruby-2.2.8@329/gems/railties-3.2.9/lib/rails/commands.rb:53:in `block in <top (required)>'
    from /home/shisongsong/.rvm/gems/ruby-2.2.8@329/gems/railties-3.2.9/lib/rails/commands.rb:50:in `tap'
    from /home/shisongsong/.rvm/gems/ruby-2.2.8@329/gems/railties-3.2.9/lib/rails/commands.rb:50:in `<top (required)>'
    from script/rails:6:in `require'
    from script/rails:6:in `<main>'

在 mysql2 的 gitbub 的 issue 也找到了一个解决方法,就是把系统的 ruby 卸载,系统的 ruby 是 2.3.5 的,但是卸载了系统中的 ruby 后,又遇到了下面的问题:

$ rails s
/usr/bin/env: "ruby2.3": 没有那个文件或目录

不知道大家有遇到过这种情况吗?

shisong 关闭了讨论。 11月27日 21:40
shisong 重新开启了讨论。 11月27日 21:41
shisong 关闭了讨论。 09月30日 18:36
需要 登录 后方可回复, 如果你还没有账号请 注册新账号