2011-06-17 38 views
0

我創建了一個運行最新Ubuntu的虛擬機,因爲它在我的Windows機器上造成了很多問題。獲取Rails在新的Ubuntu安裝上運行

我安裝了RVM,安裝版本爲1.8.7和1.9.2,默認設置爲1.9.2。我安裝了寶石,安裝了Rails。

如果我嘗試做使用Rails(生成,服務器等)什麼我得到這個錯誤:

You have requested: mysql2 ~> 0.2.6

The bundle currently has mysql2 locked at 0.2.6. Try running bundle update mysql2

第一個問題,我的Rails應用程序甚至沒有用mysql。它使用SQLite。
無論如何,我運行bundle update mysql2就像它說......我得到一堆錯誤。他們的開始是這樣的:

Installing mysql2 (0.2.6) with native extensions /home/jamesw/.rvm/rubies/ruby-1.9.2-p180/lib/ruby/site_ruby/1.9.1/rubygems/installer.rb:533:in `rescue in block in build_extensions': ERROR: Failed to build gem native extension. (Gem::Installer::ExtensionBuildError) 

     /home/jamesw/.rvm/rubies/ruby-1.9.2-p180/bin/ruby extconf.rb 
checking for rb_thread_blocking_region()... yes 
checking for mysql_query() in -lmysqlclient... no 
checking for main() in -lm... yes 
checking for mysql_query() in -lmysqlclient... no 
checking for main() in -lz... yes 
checking for mysql_query() in -lmysqlclient... no 
checking for main() in -lsocket... no 
checking for mysql_query() in -lmysqlclient... no 
checking for main() in -lnsl... yes 
checking for mysql_query() in -lmysqlclient... no 
checking for main() in -lmygcc... no 
checking for mysql_query() in -lmysqlclient... no 
*** extconf.rb failed *** 
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. 

我不擅長服務器設置和這樣的事情。我是一名OS X用戶,但在OS X上無需處理任何此類問題。任何人都可以將我指向正確的方向嗎?

回答

0

查看Gemfile,看看是否有像下面的任何一條線。

gem "mysql2" 
gem "mysql2", 0.2.6 

如果有,註釋掉或刪除這些行,請刪除Gemfile.lock並再次運行bundle install。

+0

謝謝。我應該意識到這一點。在某些時候,我將需要捆綁,但現在還不行。謝謝! –

1

如果你想擺脫MySQL的依賴,請檢查你的Gemfile,它可能是需要它的地方。

如果您好奇,mysql gem編譯失敗的原因是您可能沒有安裝mysql客戶端頭文件。對於Ubuntu,我相信「apt-get install libmysqlclient-dev」會照顧它。您還需要安裝「build-essential」軟件包。但是,如果你從你的Gemfile中刪除MySQL,所有這一切都是學術的。

+0

謝謝。我一定會記住你的第二段以備將來參考,因爲在某些時候我需要mySQL。 –