如何在Ubuntu 16.04上安装mysql2 [错误:安装mysql2时出错:错误:无法构建gem原生扩展。]

时间:2016-05-15 16:22:55

标签: ruby-on-rails ruby ubuntu

我不知道在ubuntu上安装mysql2 :(

sudo gem install mysql2
Building native extensions.  This could take a while...
ERROR:  Error installing mysql2:
ERROR: Failed to build gem native extension.

current directory: /var/lib/gems/2.3.0/gems/mysql2-0.4.4/ext/mysql2
/usr/bin/ruby2.3 -r ./siteconf20160515-9715-1s2u1sj.rb extconf.rb
mkmf.rb can't find header files for ruby at /usr/lib/ruby/include/ruby.h

extconf failed, exit code 1

Gem files will remain installed in /var/lib/gems/2.3.0/gems/mysql2-0.4.4 for inspection.
Results logged to /var/lib/gems/2.3.0/extensions/x86_64-linux/2.3.0/mysql2-0.4.4/gem_make.out

sudo apt-get install libmysqlclient-dev

Lendo listas de pacotes... Pronto
Construindo árvore de dependências       
Lendo informação de estado... Pronto
libmysqlclient-dev is already the newest version (5.7.12-0ubuntu1).
0 pacotes atualizados, 0 pacotes novos instalados, 0 a serem removidos e 61 não atualizados.

但无效

3 个答案:

答案 0 :(得分:18)

抱歉我的英语不好。

第一

sudo apt-get install libmysqlclient-dev

然后

bundle 

见!!!

答案 1 :(得分:0)

sudo apt-get install libnetcdf-dev libssl-dev libcrypto++-dev libgmp-dev

为我解决了同样的问题

答案 2 :(得分:0)

sudo apt-get install ruby-mysql2