2016-05-15 115 views
6

我不知道在Ubuntu :(如何在Ubuntu 16.04安裝mysql2 [錯誤:錯誤安裝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 

命令和apt-get安裝mysql2安裝的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. 

但不工作

+0

耙測試 '找不到寶石「mysql2(< 0.5, > = 0.3.13)」這臺機器。' 運行'bundle install'來安裝缺失的寶石。 –

+1

您是否安裝了ruby dev環境? 'sudo apt-get install ruby​​-dev' – Dawcars

+0

檢查你是否具有構建mysql2 gem本地擴展的所有其他需求。 –

回答

13

我爲我的英語不好對不起。

1)命令和apt-get安裝的libmysqlclient-dev的

2)束

見你!

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

任何在你的Gemfile或可在創業板上市資源已經解決了同樣的問題,我

0
sudo apt-get install ruby-mysql2 
+1

雖然這段代碼可能會回答這個問題,但提供了關於如何和/或爲什麼解決的附加上下文問題會改善答案的長期價值。 –

相關問題