简体   繁体   English

捆绑安装将无法使用Ruby 1.9.3,Rails3和Mac Mountain Lion安装mysql2 gem

[英]Bundle Install wont install mysql2 gem with Ruby 1.9.3, Rails3 and Mac Mountain Lion

I am unable to run Ruby on Rails bundle install with Ruby 1.9.3 and Mountain Lion. 我无法在Ruby 1.9.3和Mountain Lion上运行Ruby on Rails捆绑安装。 It will not install the MySql2 gem. 它不会安装MySql2 gem。 I have installed Ruby on Rails about 10 times on a mac OS X Lion, so I am very familiar with the steps, but am unable to get the MySQL gem into install. 我已经在Mac OS X Lion上安装了Ruby on Rails约10次,因此我对这些步骤非常熟悉,但是无法安装MySQL gem。 This is the error I get. 这是我得到的错误。 Thanks in advance. 提前致谢。

    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.

I have tried bundle install --path mysql and bundle install --system and neither worked 我试过bundle install --path mysql和bundle install --system都没有用

This guy had the same problem : Unable to install mysql2 gem OS X Mountain Lion 这个家伙有同样的问题: 无法安装mysql2 gem OS X Mountain Lion

Are you using the brew version of mysql? 您是否正在使用mysql的brew版本?

If you're using rvm, and possibly added mysql2 outside of rvm, try these steps: Confirm that your Gemfile says: 如果您使用的是rvm,并且可能在rvm之外添加了mysql2,请尝试以下步骤:确认您的Gemfile显示为:

gem 'mysql2' 宝石'mysql2'

or for Rails2.x: 或对于Rails2.x:

gem 'mysql2', '~> 0.2.11' gem'mysql2','〜> 0.2.11'

then: 然后:

    $ 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

Now rails should start properly. 现在,滑轨应该可以正常启动了。

1) first install homebrew from terminal : ruby -e "$(curl -fsSL https://raw.github.com/Homebrew/homebrew/go/install )" 1)首先从终端安装自制程序:ruby -e“ $(curl -fsSL https://raw.github.com/Homebrew/homebrew/go/install )”

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

It should work. 它应该工作。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM