如何在OS X上使用ruby 2.3解析mysql2 gem的“不兼容的库版本”?

时间:2021-12-30 07:09:43

I'm using ruby 2.3, and in the gemfile, I've got the mysql2 gem listed. But when I try to run rake db:migrate, I get the following:

我正在使用ruby 2.3,并且在gemfile中,我已经列出了mysql2 gem。但是当我尝试运行rake db:migrate时,我得到以下内容:

/Users/me/.gem/ruby/2.3.0/gems/mysql2-0.4.2/lib/mysql2.rb:31:in `require': incompatible library version - /Users/me/.gem/ruby/2.3.0/gems/mysql2-0.4.2/lib/mysql2/mysql2.bundle (fatal)

I can't seem to get around this one. I've installed Mysql 5.7 with Homebrew, tried updating the bundle, uninstalling and reinstalling the mysql2 gem, all to no avail.

我似乎无法解决这个问题。我已经用Homebrew安装了Mysql 5.7,尝试更新捆绑包,卸载并重新安装mysql2 gem,但都无济于事。

How can I get this resolved?

我怎样才能解决这个问题?

5 个解决方案

#1


34  

I ended up solving this with gem pristine --all

我最终用gem pristine解决了这个问题 - 所有

#2


6  

I have solved this with gem pristine mysql2 followed by spring stop.

我用gem pristine mysql2解决了这个问题,然后是spring stop。

#3


0  

I experienced the same issue. I had ruby 2.3.4 installed and using rails 4.6.2.

我遇到了同样的问题。我安装了ruby 2.3.4并使用了rails 4.6.2。

There were two issues causes and the support team of the hosting company I was using helped me resolve the issue.

有两个问题原因,我使用的托管公司的支持团队帮助我解决了这个问题。

The first was that the mysql2 lib that was installed was, by default, linked to ruby 1.8 instead of ruby 2

第一个是默认情况下安装的mysql2 lib链接到ruby 1.8而不是ruby 2

# lld ../2.2.0/mysql2-0.4.4/mysql2/mysql2.so
... 
...
libruby.so.1.8 => /usr/lib64/libruby.so.1.8 (0x00007f2af1f8a000)
...

Second issue was to compile the lib with the installed mysql server config

第二个问题是使用已安装的mysql服务器配置编译lib

So mysql2 gem had to be uninstalled and re-installed with the right ruby lib and compiled with the right mysql config.

因此必须卸载mysql2 gem并使用正确的ruby lib重新安装并使用正确的mysql配置进行编译。

Below are the commands.

以下是命令。

gem uninstall mysql2
gem install mysql2 -- --with-mysql-config=/usr/bin/mysql_config --with-opt-lib=/where/my/ruby22/lib_was_located/

#4


0  

I experienced this problem moving to Ubuntu 16.04

我在迁移到Ubuntu 16.04时遇到了这个问题

The following did the trick

以下是诀窍

sudo apt-get install g++
sudo apt-get install build-essential

#5


0  

running sudo gem pristine mysql2 did not work for me.

运行sudo gem pristine mysql2对我没用。

I had to uninstall and reinstall the mysql2 gem.

我不得不卸载并重新安装mysql2 gem。

#1


34  

I ended up solving this with gem pristine --all

我最终用gem pristine解决了这个问题 - 所有

#2


6  

I have solved this with gem pristine mysql2 followed by spring stop.

我用gem pristine mysql2解决了这个问题,然后是spring stop。

#3


0  

I experienced the same issue. I had ruby 2.3.4 installed and using rails 4.6.2.

我遇到了同样的问题。我安装了ruby 2.3.4并使用了rails 4.6.2。

There were two issues causes and the support team of the hosting company I was using helped me resolve the issue.

有两个问题原因,我使用的托管公司的支持团队帮助我解决了这个问题。

The first was that the mysql2 lib that was installed was, by default, linked to ruby 1.8 instead of ruby 2

第一个是默认情况下安装的mysql2 lib链接到ruby 1.8而不是ruby 2

# lld ../2.2.0/mysql2-0.4.4/mysql2/mysql2.so
... 
...
libruby.so.1.8 => /usr/lib64/libruby.so.1.8 (0x00007f2af1f8a000)
...

Second issue was to compile the lib with the installed mysql server config

第二个问题是使用已安装的mysql服务器配置编译lib

So mysql2 gem had to be uninstalled and re-installed with the right ruby lib and compiled with the right mysql config.

因此必须卸载mysql2 gem并使用正确的ruby lib重新安装并使用正确的mysql配置进行编译。

Below are the commands.

以下是命令。

gem uninstall mysql2
gem install mysql2 -- --with-mysql-config=/usr/bin/mysql_config --with-opt-lib=/where/my/ruby22/lib_was_located/

#4


0  

I experienced this problem moving to Ubuntu 16.04

我在迁移到Ubuntu 16.04时遇到了这个问题

The following did the trick

以下是诀窍

sudo apt-get install g++
sudo apt-get install build-essential

#5


0  

running sudo gem pristine mysql2 did not work for me.

运行sudo gem pristine mysql2对我没用。

I had to uninstall and reinstall the mysql2 gem.

我不得不卸载并重新安装mysql2 gem。