【问题标题】:An error occurred while installing mysql2 (0.3.21), and Bundler cannot continue安装mysql2(0.3.21)时出错,Bundler无法继续
【发布时间】:2018-06-28 18:01:00
【问题描述】:

我尝试捆绑应用程序时弹出此错误的任何原因: 我已尝试按照他们的建议安装 gem install mysql2 -v '0.3.21' 但无法正确安装。我也在 macOS High Sierra 上运行它。很抱歉我对这个问题的措辞不好,因为这是我第一次使用 ruby​​。

 To see why this extension failed to compile, please check the mkmf.log which can be found here:

  /Users/yamanshrestha/Desktop/Dorsata/vendor/bundle/ruby/2.3.0/extensions/universal-darwin-17/2.3.0/mysql2-0.3.21/mkmf.log

current directory: /Users/yamanshrestha/Desktop/Dorsata/vendor/bundle/ruby/2.3.0/gems/mysql2-0.3.21/ext/mysql2
make "DESTDIR=" clean

current directory: /Users/yamanshrestha/Desktop/Dorsata/vendor/bundle/ruby/2.3.0/gems/mysql2-0.3.21/ext/mysql2
make "DESTDIR="
compiling infile.c
compiling client.c
client.c:439:3: error: use of undeclared identifier 'my_bool'
  my_bool res = mysql_read_query_result(client);
  ^
client.c:441:19: error: use of undeclared identifier 'res'
  return (void *)(res == 0 ? Qtrue : Qfalse);
                  ^
client.c:762:3: error: use of undeclared identifier 'my_bool'
  my_bool boolval;
  ^
client.c:793:7: error: use of undeclared identifier 'boolval'
      boolval = (value == Qfalse ? 0 : 1);
      ^
client.c:794:17: error: use of undeclared identifier 'boolval'
      retval = &boolval;
                ^
client.c:797:10: error: use of undeclared identifier 'MYSQL_SECURE_AUTH'; did you mean 'MYSQL_DEFAULT_AUTH'?
    case MYSQL_SECURE_AUTH:
         ^~~~~~~~~~~~~~~~~
         MYSQL_DEFAULT_AUTH
/usr/local/Cellar/mysql/8.0.11/include/mysql/mysql.h:188:3: note: 'MYSQL_DEFAULT_AUTH' declared here
  MYSQL_DEFAULT_AUTH,
  ^
client.c:798:7: error: use of undeclared identifier 'boolval'
      boolval = (value == Qfalse ? 0 : 1);
      ^
client.c:799:17: error: use of undeclared identifier 'boolval'
      retval = &boolval;
                ^
client.c:830:38: error: use of undeclared identifier 'boolval'
        wrapper->reconnect_enabled = boolval;
                                     ^
client.c:1185:38: error: use of undeclared identifier 'MYSQL_SECURE_AUTH'; did you mean 'MYSQL_DEFAULT_AUTH'?
  return _mysql_client_options(self, MYSQL_SECURE_AUTH, value);
                                     ^~~~~~~~~~~~~~~~~
                                     MYSQL_DEFAULT_AUTH
/usr/local/Cellar/mysql/8.0.11/include/mysql/mysql.h:188:3: note: 'MYSQL_DEFAULT_AUTH' declared here
  MYSQL_DEFAULT_AUTH,
  ^
10 errors generated.
make: *** [client.o] Error 1

make failed, exit code 2

Gem files will remain installed in /Users/yamanshrestha/Desktop/Dorsata/vendor/bundle/ruby/2.3.0/gems/mysql2-0.3.21 for inspection.
Results logged to /Users/yamanshrestha/Desktop/Dorsata/vendor/bundle/ruby/2.3.0/extensions/universal-darwin-17/2.3.0/mysql2-0.3.21/gem_make.out

An error occurred while installing mysql2 (0.3.21), and Bundler cannot continue.
Make sure that `gem install mysql2 -v '0.3.21' --source 'http://rubygems.org/'` succeeds before bundling.

【问题讨论】:

  • 你能添加他们提到的那个日志文件的内容吗?

标签: mysql ruby-on-rails bundle-install


【解决方案1】:

通过降级我的mysql来修复。并使用mysql v5.7编译mysql2。

对于 Mac 用户:

brew install mysql@5.7

gem install mysql2 -v '0.3.21' -- --with-mysql-include=/usr/local/Cellar/mysql@5.7/5.7.25/include/mysql --with-mysql-lib=/usr/local/Cellar/mysql@5.7/5.7.25/lib

参考:https://github.com/brianmario/mysql2#configuration-options

【讨论】:

    【解决方案2】:

    所以,我环顾四周后设法自己解决了这个问题。基本上,与编写的代码相比,gemfile 中编写的 mysql2 版本已经过时,因此版本之间的语法差异导致在尝试安装 mysql2 时出现此错误。因此,要解决这个问题,您必须转到您的 gemfile,然后更改 mysql2 的版本号。我将地雷更改为以下内容:

     gem 'mysql2', '~> 0.4.10'
    

    保存文件并再次尝试安装,它应该可以工作

    【讨论】:

    • 为我工作,Ruby 2.3.8 和 Rails 3.2.11
    【解决方案3】:

    对于 ubuntu,这个帮助了我:

    sudo apt-get -f install
    sudo apt-get update
    sudo apt-get install libmysqlclient-dev
    bundle install
    

    我在这里找到了这个https://github.com/brianmario/mysql2/issues/445

    【讨论】:

      【解决方案4】:

      对我来说,解决方案是安装 mysql-connector-c,brew install mysql-connector-c。在我的特殊情况下,它已经安装了,但我不得不用强制覆盖重新链接它(控制台中的消息会告诉你在你的情况下该怎么做)。

      【讨论】:

        【解决方案5】:

        我有同样的问题。正如您在错误中看到的那样,存在代码解释问题。这是由于用 gemfile 编写的和代码中使用的 mysql2 的版本不匹配造成的。 为了解决这个问题,我运行:
        - gem install mysql2(它将安装最新的 msql2 版本)
        - 在我的 gemfile 中,我将:gem 'mysql2','~>0.3.1' 更改为 gem 'mysql2'

        【讨论】:

          猜你喜欢
          • 2018-01-10
          • 2022-07-08
          • 2014-11-07
          • 2014-11-04
          • 1970-01-01
          • 2016-03-14
          • 2022-01-20
          • 2017-02-09
          • 2018-09-08
          相关资源
          最近更新 更多