2012-07-27 142 views
7

我們實習生的電腦在安裝mysql2 gem時遇到問題。我們只是將他的電腦從OS X 10.6升級到了10.8(Mountain Lion)。我曾嘗試通過自制軟件和64位DMG安裝程序安裝MySQL。我也嘗試了對開發工具的符號鏈接(正如這裏指出的:Not able to install some gems after mountain lion upgrade)。我們安裝了Xcode(4.4)並安裝了命令行工具。我們在安裝命令行工具後嘗試重新啓動。mysql2 gem無法構建原生擴展

這是~/.bashrc他的PATH聲明:

PATH=/usr/local/bin:$PATH:$HOME/.rvm/bin:/usr/local/mysql/bin # Add RVM to PATH for scripting 

符號鏈接:

Diego-Blantons-MacBook-Pro-3:~ lmrunner07$ sudo ln -s /usr/bin/llvm-gcc-4.2 /usr/bin/gcc-4.2 
Password: 

嘗試安裝寶石:

Diego-Blantons-MacBook-Pro-3:~ lmrunner07$ gem install mysql2 
Building native extensions.  This could take a while... 
ERROR:  Error installing mysql2: 
   ERROR: Failed to build gem native extension. 

       /Users/lmrunner07/.rvm/rubies/ruby-1.9.3-p194/bin/ruby extconf.rb 
checking for rb_thread_blocking_region()... yes 
checking for rb_wait_for_single_fd()... yes 
checking for mysql.h... yes 
checking for errmsg.h... yes 
checking for mysqld_error.h... yes 
creating Makefile 

make 
compiling client.c 
In file included from /Users/lmrunner07/.rvm/rubies/ruby-1.9.3-p194/include/ruby-1.9.1/ruby.h:32, 
                from ./mysql2_ext.h:8, 
                from client.c:1: 
/Users/lmrunner07/.rvm/rubies/ruby-1.9.3-p194/include/ruby-1.9.1/ruby/ruby.h:105: error: size of array ‘ruby_check_sizeof_long’ is negative 
/Users/lmrunner07/.rvm/rubies/ruby-1.9.3-p194/include/ruby-1.9.1/ruby/ruby.h:109: error: size of array ‘ruby_check_sizeof_voidp’ is negative 
In file included from /Users/lmrunner07/.rvm/rubies/ruby-1.9.3-p194/include/ruby-1.9.1/ruby/intern.h:34, 
               from /Users/lmrunner07/.rvm/rubies/ruby-1.9.3-p194/include/ruby-1.9.1/ruby/ruby.h:1382, 
                from /Users/lmrunner07/.rvm/rubies/ruby-1.9.3-p194/include/ruby-1.9.1/ruby.h:32, 
                from ./mysql2_ext.h:8, 
                from client.c:1: 
/Users/lmrunner07/.rvm/rubies/ruby-1.9.3-p194/include/ruby-1.9.1/ruby/st.h:67: error: size of array ‘st_check_for_sizeof_st_index_t’ is negative 
client.c: In function ‘rb_raise_mysql2_error’: 
client.c:98: warning: ISO C90 forbids mixed declarations and code 
client.c: In function ‘rb_mysql_client_socket’: 
client.c:590: warning: ISO C90 forbids mixed declarations and code 
make: *** [client.o] Error 1 


Gem files will remain installed in /Users/lmrunner07/.rvm/gems/ruby-1.9.3-p194/gems/mysql2-0.3.11 for inspection. 
Results logged to /Users/lmrunner07/.rvm/gems/ruby-1.9.3-p194/gems/mysql2-0.3.11/ext/mysql2/gem_make.out 

我已經刪除了自制mysql安裝以及作爲發射代理。此外rm -rf寶石目錄(用戶/ lmrunner07/.rvm /寶石/紅寶石1.9.3-P194 /寶石/ mysql2-0.3.11)

+0

您可以驗證您的Xcode 4.4版本是重新發布兩個獅子和山獅? – davidcelis 2012-07-27 18:21:06

+0

對不起,您想要我檢查什麼? – 2012-07-27 18:36:38

+0

當Mountain Lion發佈時,他們更新了應用商店中的Xcode 4.4,使其成爲兼容Lion和Mountain Lion的版本。如果你沒有重新安裝Xcode,很可能你的版本只與以前版本的OS X兼容。 – davidcelis 2012-07-27 18:43:53

回答

5

我解決了這個由:

  1. 安裝自制ruby <(curl -fsSk https://raw.github.com/mxcl/homebrew/go) (看看他們的使用率http://mxcl.github.com/homebrew/網站)
  2. 按照這些指令http://robots.thoughtbot.com/post/27985816073/the-hitchhikers-guide-to-riding-a-mountain-lion
  3. 重新安裝的MySQL與自制brew install mysql。 (我試圖按照這些指示http://erictarn.com/post/28269453881/how-i-installed-mysql-rvm-ruby-and-rails-on-mountain安裝MySQL,但我遇到了問題以後,所以我會建議重新安裝的MySQL與自制。)
  4. 重新安裝RVM和軌和我的項目寶石(其中包括mysql2)

注:(參見Library not loaded: libmysqlclient.16.dylib error when trying to run 'rails server' on OS X 10.6 with mysql2 gem如果你得到了同樣的問題)當我試圖建立我有一個圖書館的問題,Library not loaded: libmysqlclient.18.dylib,這是固定的運行sudo ln -s /usr/local/mysql/lib/libmysqlclient.18.dylib /usr/lib/libmysqlclient.18.dylib

+0

實習生今天不在,所以我無法嘗試。如果如果有效,我會回來點。感謝您的鏈接 – 2012-08-06 17:15:07

+0

第2步中的鏈接做到了。不知道哪一步做到了,但謝謝! – 2012-08-07 17:20:15

+0

不用擔心。謝謝你的觀點。我很高興它的工作。花了好幾個小時才自己解決。我以爲我應該分享。 – Harro 2012-08-07 19:50:45

0

你試過:

gem install mysql2 --with-mysql-config=/usr/lib64/mysql/mysql_config 

更換/usr/lib64/mysql/mysql_config用你的mysql配置的位置。

+0

我想這個命令是:'gem install mysql2 - --with-mysql-config =/usr/lib64/mysql/mysql_config'?(額外' - ')得到了相同的結果,雖然 – 2012-07-27 18:46:58

0

不幸的是,安裝過程是非常細分化的,如果沒有全面查看您的步驟,很難隔離您的問題。

不知道更多關於你的安裝步驟,這裏有一些我注意到的事情讓我看到了一個穩定的Rails Mountain Lion開發框(同樣道歉,這不是更具體)。

  1. 說明RVM,紅寶石:moncefbelyamani.com

    注:有一定的步驟在這裏,我通過了建議從brew doctor'rvm requirements'我從來沒有在以前的設置拍攝。

    注意事項,如:

    • 的Xcode 4.3或更高版本僅使用Ruby-1.9.3-P125 +(並告訴我,如果我有編譯問題降級到的Xcode 4.1)
    • 使用brew install autoconf automake apple-gcc42
    • 使用brew tap homebrew/dupes
    • 和別人...
  2. 個Rails的具體說明:railsapps.github.com

  3. 爲MySQL(跳到下安裝的MySQL的部分:coolestguyplanettech.com

注:我做了可選步驟: ...爲了使用而無需鍵入命令的MySQL您需要將mysql目錄添加到shell路徑的命令的完整路徑...,因爲我發現這樣做可以幫助在構建等(一些腳本假設...)

在這裏,我試圖簡單地創建一個新的rails應用程序與默認數據庫是mysql(這將關閉mysql2通過捆綁)。從那裏 - 我試圖做一個快速腳手架測試應用程序 - 和mysql2 barfed。

從那裏我遇到錯誤「庫未加載:libmysqlclient.16.dylib」和這裏要注意:stackoverflow awesomeness 我加入這行到我的.profile文件:export DYLD_LIBRARY_PATH=/usr/local/mysql/lib:$DYLD_LIBRARY_PATH

我的道路包括軌道和紅寶石明確:/Users/gabriel/.rvm/gems/[email protected]/bin:/Users/gabriel/.rvm/gems/[email protected]/bin:/Users/gabriel/.rvm/rubies/ruby-1.9.3-p194/bin:/Users/gabriel/.rvm/bin:/usr/local/mysql/bin:/usr/local/bin:/usr/bin:/usr/sbin:/opt/X11/bin:

希望這些資源能提供一些額外的幫助。

+0

實習生今天出去了,所以我不能試試這個。如果如果有效,我會回來點。感謝您的鏈接 – 2012-08-06 17:14:43

0

我能得到它的運行編譯: PATH =/bin:/ usr/bin:/ opt/mysql5_64/bin gem install mysql2 W這裏mysql5_64我下載了最新的64位版本的mysql並在那裏提取。離開我已經安裝的mysql數據庫。

0

我能通過implode -ing rvm解決這個問題並安裝Homebrew的紅寶石。然後,mysql2 gem安裝就好了。

這不是像我遇到過的第一個問題。我不認爲我會再次使用它。

0

我有這個在OSX約塞米蒂成功運行:

sudo port install mysql56 
gem install mysql2 -- --with-mysql-config=/opt/local/lib/mysql56/bin/mysql_config 
相關問題