无法在Ubuntu 16.04.3 LTS上安装gem mysql2

时间:2017-08-20 12:53:32

标签: ruby rubygems mysql2

当我运行gem install mysql2命令时,我收到以下错误消息:

Building native extensions.  This could take a while...
ERROR:  Error installing mysql2:
    ERROR: Failed to build gem native extension.
...
Could not create Makefile due to some reason, probably lack of necessary
libraries and/or headers.  Check the mkmf.log file for more details.  You may
need configuration options.
... 
To see why this extension failed to compile, please check the mkmf.log which can be found here:

  /home/lucivaldo/.rvm/gems/ruby-2.4.0/extensions/x86_64-linux/2.4.0/mysql2-0.4.9/mkmf.log

extconf failed, exit code 1

Gem files will remain installed in /home/lucivaldo/.rvm/gems/ruby-2.4.0/gems/mysql2-0.4.9 for inspection.
Results logged to /home/lucivaldo/.rvm/gems/ruby-2.4.0/extensions/x86_64-linux/2.4.0/mysql2-0.4.9/gem_make.out

查看消息末尾描述的日志文件,我发现有些库丢失了。

如何解决这个问题?

2 个答案:

答案 0 :(得分:0)

在Stack Overflow本身搜索,我找到了另一个类似于以下命令的问题的解决方案,它也解决了这个问题:

sudo apt install libgmp3-dev

答案 1 :(得分:0)

尝试安装客户端库:

sudo apt-get install ruby-mysql libmysqlclient-dev