issue in installing mysql2 gem with rails3 on mac

前端 未结 3 482
暖寄归人
暖寄归人 2020-12-19 20:34
 Installing mysql2 (0.2.6) with native extensions /Library/Ruby/Site/1.8/rubygems/installer.rb:483:in `build_extensions\': ERROR: Failed to build gem native extensio         


        
相关标签:
3条回答
  • 2020-12-19 21:22

    Try installing mysql from macports

    sudo ports install mysql5
    

    It took ages to complete, but once done run

    gem install mysql2
    

    and everything should work just fine

    0 讨论(0)
  • 2020-12-19 21:24

    download 64 bit from here and then try to install mysql2 gem

    http://dev.mysql.com/downloads/mysql/

    it will work..

    0 讨论(0)
  • 2020-12-19 21:33

    Try the following, which seems to have worked for others:

    1. From the Terminal, run locate mysql_config and identify the path to the mysql_config binary
    2. Use that path in the following command to install the gem:sudo gem install mysql2 -- –with-mysql-config=/path/you/identified/above/mysql_config

    [Edit]

    In response to the new error, e.g.:

    Mohit-Jains-MacBook-Pro:casecreed mohit$ rake db:create
    (in /Users/mohit/projects/casecreed)
    rake aborted!
    dlopen(/Library/Ruby/Gems/1.8/gems/mysql2-0.2.6/lib/mysql2/mysql2.bundle, 9): Library not loaded: libmysqlclient.16.dylib
      Referenced from: /Library/Ruby/Gems/1.8/gems/mysql2-0.2.6/lib/mysql2/mysql2.bundle
      Reason: image not found - /Library/Ruby/Gems/1.8/gems/mysql2-0.2.6/lib/mysql2/mysql2.bundle
    /Users/mohit/projects/casecreed/Rakefile:4
    (See full trace by running task with --trace
    

    I believe this is due to mysql2 not using the full path to libmysqlclient.16.dylib. Others have had luck with:

    sudo install_name_tool -change libmysqlclient.16.dylib /usr/local/mysql/lib/libmysqlclient.16.dylib /Library/Ruby/Gems/1.8/gems/mysql2-0.2.6/lib/mysql2/mysql2.bundle
    

    However, be sure to replace /usr/local/mysql/lib/libmysqlclient.16.dylib with the path to your own libmysqlclient.16.dylib. I'm not positive what it would be, but you may be able to find it with locate (if not, check around in the lib directory for /usr/local/mysql-5.5.9-osx10.6-x86_64).

    0 讨论(0)
提交回复
热议问题