【问题标题】:Bundle Install wont install mysql2 gem with Ruby 1.9.3, Rails3 and Mac Mountain LionBundle Install 不会使用 Ruby 1.9.3、Rails3 和 Mac Mountain Lion 安装 mysql2 gem
【发布时间】:2012-11-18 10:41:18
【问题描述】:

我无法使用 Ruby 1.9.3 和 Mountain Lion 运行 Ruby on Rails 捆绑安装。它不会安装 MySql2 gem。我在 Mac OS X Lion 上安装了 Ruby on Rails 大约 10 次,所以我非常熟悉这些步骤,但无法安装 MySQL gem。这是我得到的错误。提前致谢。

    Gem::Installer::ExtensionBuildError: ERROR: Failed to build gem native extension.

            /Users/username/.rvm/rubies/ruby-1.9.3-p327/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 client.c:1:
    In file included from ./mysql2_ext.h:8:
    In file included from /Users/username/.rvm/rubies/ruby-1.9.3-p327/include/ruby-1.9.1/ruby.h:32:
    /Users/username/.rvm/rubies/ruby-1.9.3-p327/include/ruby-1.9.1/ruby/ruby.h:105:37: error: 'ruby_check_sizeof_long' declared as an array with a negative size
    typedef char ruby_check_sizeof_long[SIZEOF_LONG == sizeof(long) ? 1 : -1];
                                        ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    /Users/username/.rvm/rubies/ruby-1.9.3-p327/include/ruby-1.9.1/x86_64-darwin12.2.0/ruby/config.h:24:21: note: expanded from macro 'SIZEOF_LONG'
    #define SIZEOF_LONG 8
                        ^
    In file included from client.c:1:
    In file included from ./mysql2_ext.h:8:
    In file included from /Users/username/.rvm/rubies/ruby-1.9.3-p327/include/ruby-1.9.1/ruby.h:32:
    /Users/username/.rvm/rubies/ruby-1.9.3-p327/include/ruby-1.9.1/ruby/ruby.h:109:38: error: 'ruby_check_sizeof_voidp' declared as an array with a negative size
    typedef char ruby_check_sizeof_voidp[SIZEOF_VOIDP == sizeof(void*) ? 1 : -1];
                                         ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    /Users/username/.rvm/rubies/ruby-1.9.3-p327/include/ruby-1.9.1/x86_64-darwin12.2.0/ruby/config.h:28:22: note: expanded from macro 'SIZEOF_VOIDP'
    #define SIZEOF_VOIDP 8
                         ^
    In file included from client.c:1:
    In file included from ./mysql2_ext.h:8:
    In file included from /Users/username/.rvm/rubies/ruby-1.9.3-p327/include/ruby-1.9.1/ruby.h:32:
    In file included from /Users/username/.rvm/rubies/ruby-1.9.3-p327/include/ruby-1.9.1/ruby/ruby.h:1382:
    In file included from /Users/username/.rvm/rubies/ruby-1.9.3-p327/include/ruby-1.9.1/ruby/intern.h:34:
    /Users/username/.rvm/rubies/ruby-1.9.3-p327/include/ruby-1.9.1/ruby/st.h:67:45: error: 'st_check_for_sizeof_st_index_t' declared as an array with a negative size
    typedef char st_check_for_sizeof_st_index_t[SIZEOF_VOIDP == (int)sizeof(st_index_t) ? 1 : -1];
                                                ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    /Users/username/.rvm/rubies/ruby-1.9.3-p327/include/ruby-1.9.1/x86_64-darwin12.2.0/ruby/config.h:28:22: note: expanded from macro 'SIZEOF_VOIDP'
    #define SIZEOF_VOIDP 8
                         ^
    3 errors generated.
    make: *** [client.o] Error 1


    Gem files will remain installed in /Users/username/.rvm/gems/ruby-1.9.3-p327/gems/mysql2-0.3.11 for inspection.
    Results logged to /Users/username/.rvm/gems/ruby-1.9.3-p327/gems/mysql2-0.3.11/ext/mysql2/gem_make.out
    An error occurred while installing mysql2 (0.3.11), and Bundler cannot continue.
    Make sure that `gem install mysql2 -v '0.3.11'` succeeds before bundling.

我试过 bundle install --path mysql 和 bundle install --system 都没有成功

【问题讨论】:

    标签: mysql ruby-on-rails osx-mountain-lion


    【解决方案1】:

    1) 首先从终端安装自制软件: ruby -e "$(curl -fsSL https://raw.github.com/Homebrew/homebrew/go/install)"

    2) 安装 mysql : "brew install mysql" 3) 安装 mtsql2 : "gem install mysql2"

    它应该可以工作。

    【讨论】:

      【解决方案2】:

      这家伙也有同样的问题:Unable to install mysql2 gem OS X Mountain Lion

      你用的是 brew 版本的 mysql 吗?

      【讨论】:

        【解决方案3】:

        如果您使用的是 rvm,并且可能在 rvm 之外添加了 mysql2,请尝试以下步骤:确认您的 Gemfile 显示:

        宝石'mysql2'

        或者对于 Rails2.x:

        gem 'mysql2', '~> 0.2.11'

        然后:

            $ cd RAILS_ROOT $ gem uninstall mysql2
        
            Select gem to uninstall:
             1. mysql2-0.2.11
             2. mysql2-0.3.6
             3. All versions
            > 3 # select "All versions" 
        $ rvm gemset install mysql2
         $ bundle install
        

        现在 rails 应该可以正常启动了。

        【讨论】:

        • 我在安装 RVM 之前安装了 mysql,但这些对我不起作用。谢谢
        • 在执行“rvm gemset install mysql2”时出现同样的错误。 "ruby/config.h:28:22: 注意:扩展自宏 'SIZEOF_VOIDP' #define SIZEOF_VOIDP 8"
        猜你喜欢
        • 1970-01-01
        • 2012-08-10
        • 2013-04-13
        • 1970-01-01
        • 2011-11-16
        • 1970-01-01
        • 1970-01-01
        • 2012-02-28
        • 2021-11-04
        相关资源
        最近更新 更多