2011-04-24 206 views
2

可能重複:
In my rails 3 app, simple_captcha doesn't display image on production mode安裝mysql2寶石錯誤

我通過macport但創業板名單安裝Ruby和Ruby寶石不包括mysql2。那麼我怎麼會得到安裝在我的寶石列表裏面的「/ opt/local/bin/gem」中的mysql2 gem

另外,什麼是mysql2 gem?我有MySQL的寶石,只想使用MySQL,不確定是什麼意思的MySQL2。當我嘗試在應用上啓動webrick時,它會給我一個mysql2錯誤。

感謝

更新: 我RAM sudo的創業板安裝mysql2,得到了以下幾點:

大廈原生擴展。這 可能需要一段時間...成功 安裝mysql2-0.2.7 1寶石安裝 爲 mysql2-0.2.7安裝文件裏...

封閉類/模塊「mMysql2」的 類客戶端不衆所周知

封閉類/模塊「mMysql2」不知道安裝的RDoc 文檔mysql2-0.2.7 ... 類結果

封閉類/模塊「mMysql2」的 類客戶端不知道

封閉類/模塊「mMysql2」的 類結果不知道mysql2安裝

Asuming,即使文檔我纔不會收到以下錯誤,當我嘗試在我的應用程序啓動的WEBrick。

軌服務器:

/opt/local/lib/ruby/gems/1.8/gems/mysql2-0.2.7/lib/mysql2/mysql2.bundle: 的dlopen(/選擇/本地/ LIB /紅寶石/寶石/ 1.8 /寶石/ mysql2-0.2.7/LIB/mysql2/mysql2.bundle, 9):庫未加載: libmysqlclient.18.dylib(LoadError)從參考
: /選擇/ local/lib/ruby​​/gems/1.8/gems/mysql2-0.2.7/lib/mysql2/mysql2.bundle 原因:image not found - /opt/local/lib/ruby/gems/1.8/gems/mysql2- 0.2.7/lib/mysql2/mysql2.bundle from /opt/local/lib/ruby/gems/1.8/gems/mysql2-0.2.7/lib/mysql2.rb:8 from /opt/local/lib/ruby/gems/1.8/gems/bundler- 1.0.7/lib/bundler/runtime.rb:64: require' from /opt/local/lib/ruby/gems/1.8/gems/bundler-1.0.7/lib/bundler/runtime.rb:64:in require'from /opt/local/lib/ruby/gems/1.8/gems/bundler-1.0.7/lib/bundler/runtime.rb: 62:在 each' from /opt/local/lib/ruby/gems/1.8/gems/bundler-1.0.7/lib/bundler/runtime.rb:62:in 需要 '從 /opt/local/lib/ruby/gems/1.8/gems/bundler-1.0.7/lib/bundler/runtime.rb:51:in each' from /opt/local/lib/ruby/gems/1.8/gems/bundler-1.0.7/lib/bundler/runtime.rb:51:in 需要' 從 /選擇/ local/lib目錄/紅寶石/寶石/ 1.8 /寶石/捆紮機-1.0.7/lib目錄/捆綁。rb:112: require' from /Users/summer/Sites/simple_cms/config/application.rb:7 from /opt/local/lib/ruby/gems/1.8/gems/railties-3.0.7/lib/rails/commands.rb:28:in require'from /opt/local/lib/ruby/gems/1.8/gems/railties-3.0.7/lib/rails/commands.rb:28 from /opt/local/lib /ruby/gems/1.8/gems/railties-3.0.7/lib/rails/commands.rb:27:in tap' from /opt/local/lib/ruby/gems/1.8/gems/railties-3.0.7/lib/rails/commands.rb:27 from script/rails:6:in需要」 從腳本/軌道:6

+0

你缺少的libmysqlclient-dev的頭試圖尋找在MacPorts的該庫。這是我必須安裝在我的Ubuntu上,以安裝寶石。 – sirfilip 2011-05-06 06:49:53

+0

如何將一個完全不相關的問題標記爲重複? – 2015-03-16 22:51:41

回答

2

據我所知,兩個gem(mysql和mysql2)之間的區別之一是mysql2在UTF-8上效果更好。這裏有關於它的is an article

要安裝mysql2寶石,只需要運行:

gem install 'mysql2' 
+0

@amokrane出現錯誤,將其粘貼在問題 – Saad 2011-04-24 22:47:23

+0

以上請查看此頁:http://stackoverflow.com/questions/4115126/ruby-gem-mysql2 -install-失敗。閱讀所有答案,特別是來自Holger Just的答案。 – 2011-04-24 22:52:42

+0

但是從你的日誌看來,這個寶石看起來實際上已經安裝好了,錯誤只是與文檔相關! – 2011-04-24 22:54:36

2

爲了執行用於搜索遠程寶石可用運行命令 寶石搜索mysql2 -R(注意最後的-r)

* REMOTE GEMS *

了activerecord-mysql2legacydb適配器(0.2.0) 了activerecord-mysql2spatial適配器(0.3.2) em_mysql2_connection_pool(0.0.5) ghazel-mysql2(0.2.6.3) mysql2(0.2.7,0.2。 6 x86的的mingw32 x86的mswin32-60) mysql2_bigint(0.2.6.1) mysql2_model(0.1.2) mysql2mysql(0.0.2) mysql2psql(0.1.0) mysql2xxxx(0.0.4)

從你應該選擇mysql2的寶石列表並運行 sudo gem install mysql2

+0

@sirfillip出現錯誤,將其粘貼在問題 – Saad 2011-04-24 22:47:02