Warning: file_get_contents(/data/phpspider/zhask/data//catemap/5/ruby/20.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Mysql2 Gem版本0.3.18 uptill 0.4.x韩元';t安装在我的RubyonRails项目Ubuntu中_Mysql_Ruby_Ruby On Rails 4_Rubygems_Mysql2 - Fatal编程技术网

Mysql2 Gem版本0.3.18 uptill 0.4.x韩元';t安装在我的RubyonRails项目Ubuntu中

Mysql2 Gem版本0.3.18 uptill 0.4.x韩元';t安装在我的RubyonRails项目Ubuntu中,mysql,ruby,ruby-on-rails-4,rubygems,mysql2,Mysql,Ruby,Ruby On Rails 4,Rubygems,Mysql2,我正在从事RubyonRails遗留项目。我试图在我的系统(Ubuntu 20.4)中设置整个项目环境,但我面临以下问题: 运行bundle安装时,出现以下错误: An error occurred while installing mysql2 (0.3.21), and Bundler cannot continue. Make sure that `gem install mysql2 -v '0.3.21' --source 'https://rubygems.org/'` succee

我正在从事RubyonRails遗留项目。我试图在我的系统(Ubuntu 20.4)中设置整个项目环境,但我面临以下问题:

运行bundle安装时,出现以下错误:

An error occurred while installing mysql2 (0.3.21), and Bundler cannot continue.
Make sure that `gem install mysql2 -v '0.3.21' --source 'https://rubygems.org/'` succeeds before bundling.
当我再次运行
gem安装mysql2-v“0.3.21”-source时https://rubygems.org/“
我得到以下错误:

Building native extensions. This could take a while...
ERROR:  Error installing mysql2:
    ERROR: Failed to build gem native extension.

    current directory: /home/syed/.rvm/gems/ruby-2.2.2/gems/mysql2-0.3.21/ext/mysql2
/usr/share/rvm/rubies/ruby-2.2.2/bin/ruby -I /usr/share/rvm/rubies/ruby-2.2.2/lib/ruby/site_ruby/2.2.0 -r ./siteconf20201005-54852-6qy3z2.rb extconf.rb
checking for ruby/thread.h... yes
checking for rb_thread_call_without_gvl() in ruby/thread.h... yes
checking for rb_thread_blocking_region()... no
checking for rb_wait_for_single_fd()... yes
checking for rb_hash_dup()... yes
checking for rb_intern3()... yes
-----
Using mysql_config at /usr/bin/mysql_config
-----
checking for mysql.h... yes
checking for errmsg.h... yes
checking for mysqld_error.h... yes
-----
Setting libpath to /usr/lib/x86_64-linux-gnu
-----
creating Makefile

current directory: /home/syed/.rvm/gems/ruby-2.2.2/gems/mysql2-0.3.21/ext/mysql2
make "DESTDIR=" clean

current directory: /home/syed/.rvm/gems/ruby-2.2.2/gems/mysql2-0.3.21/ext/mysql2
make "DESTDIR="
compiling infile.c
compiling client.c
client.c: In function ‘nogvl_read_query_result’:
client.c:439:3: error: unknown type name ‘my_bool’; did you mean ‘bool’?
  439 |   my_bool res = mysql_read_query_result(client);
      |   ^~~~~~~
      |   bool
client.c: In function ‘_mysql_client_options’:
client.c:762:3: error: unknown type name ‘my_bool’; did you mean ‘bool’?
  762 |   my_bool boolval;
      |   ^~~~~~~
      |   bool
client.c:797:10: error: ‘MYSQL_SECURE_AUTH’ undeclared (first use in this function); did you mean ‘MYSQL_DEFAULT_AUTH’?
  797 |     case MYSQL_SECURE_AUTH:
      |          ^~~~~~~~~~~~~~~~~
      |          MYSQL_DEFAULT_AUTH
client.c:797:10: note: each undeclared identifier is reported only once for each function it appears in
client.c: In function ‘set_secure_auth’:
client.c:1185:38: error: ‘MYSQL_SECURE_AUTH’ undeclared (first use in this function); did you mean ‘MYSQL_DEFAULT_AUTH’?
 1185 |   return _mysql_client_options(self, MYSQL_SECURE_AUTH, value);
      |                                      ^~~~~~~~~~~~~~~~~
      |                                      MYSQL_DEFAULT_AUTH
client.c:1186:1: warning: control reaches end of non-void function [-Wreturn-type]
 1186 | }
      | ^
make: *** [Makefile:238: client.o] Error 1

make failed, exit code 2

Gem files will remain installed in /home/syed/.rvm/gems/ruby-2.2.2/gems/mysql2-0.3.21 for inspection.
Results logged to /home/syed/.rvm/gems/ruby-2.2.2/extensions/x86_64-linux/2.2.0/mysql2-0.3.21/gem_make.out
  • Ubuntu-20.4

  • Ruby-2.2.2

  • 轨道-4.2.2

  • rvm-1.29.10

  • MySQL(服务器、客户端等)-8.0.21-0ubuntu0.20.04.4

我尝试过的事情:

  • 捆绑安装

  • 包更新

  • 将MySQL版本降级到5.x.x

  • 尝试安装其他版本的mysql2 gems,如4.x.x

  • 在我的gem文件中:
    gem'mysql2','~>0.3.21'

    在我的Gemlock文件中:
    mysql2(0.3.21)

    无论我做什么,在执行
    捆绑安装时都会出现以下错误:

    Building native extensions. This could take a while...
    ERROR:  Error installing mysql2:
        ERROR: Failed to build gem native extension.
    
        current directory: /home/syed/.rvm/gems/ruby-2.2.2/gems/mysql2-0.3.21/ext/mysql2
    /usr/share/rvm/rubies/ruby-2.2.2/bin/ruby -I /usr/share/rvm/rubies/ruby-2.2.2/lib/ruby/site_ruby/2.2.0 -r ./siteconf20201005-54852-6qy3z2.rb extconf.rb
    checking for ruby/thread.h... yes
    checking for rb_thread_call_without_gvl() in ruby/thread.h... yes
    checking for rb_thread_blocking_region()... no
    checking for rb_wait_for_single_fd()... yes
    checking for rb_hash_dup()... yes
    checking for rb_intern3()... yes
    -----
    Using mysql_config at /usr/bin/mysql_config
    -----
    checking for mysql.h... yes
    checking for errmsg.h... yes
    checking for mysqld_error.h... yes
    -----
    Setting libpath to /usr/lib/x86_64-linux-gnu
    -----
    creating Makefile
    
    current directory: /home/syed/.rvm/gems/ruby-2.2.2/gems/mysql2-0.3.21/ext/mysql2
    make "DESTDIR=" clean
    
    current directory: /home/syed/.rvm/gems/ruby-2.2.2/gems/mysql2-0.3.21/ext/mysql2
    make "DESTDIR="
    compiling infile.c
    compiling client.c
    client.c: In function ‘nogvl_read_query_result’:
    client.c:439:3: error: unknown type name ‘my_bool’; did you mean ‘bool’?
      439 |   my_bool res = mysql_read_query_result(client);
          |   ^~~~~~~
          |   bool
    client.c: In function ‘_mysql_client_options’:
    client.c:762:3: error: unknown type name ‘my_bool’; did you mean ‘bool’?
      762 |   my_bool boolval;
          |   ^~~~~~~
          |   bool
    client.c:797:10: error: ‘MYSQL_SECURE_AUTH’ undeclared (first use in this function); did you mean ‘MYSQL_DEFAULT_AUTH’?
      797 |     case MYSQL_SECURE_AUTH:
          |          ^~~~~~~~~~~~~~~~~
          |          MYSQL_DEFAULT_AUTH
    client.c:797:10: note: each undeclared identifier is reported only once for each function it appears in
    client.c: In function ‘set_secure_auth’:
    client.c:1185:38: error: ‘MYSQL_SECURE_AUTH’ undeclared (first use in this function); did you mean ‘MYSQL_DEFAULT_AUTH’?
     1185 |   return _mysql_client_options(self, MYSQL_SECURE_AUTH, value);
          |                                      ^~~~~~~~~~~~~~~~~
          |                                      MYSQL_DEFAULT_AUTH
    client.c:1186:1: warning: control reaches end of non-void function [-Wreturn-type]
     1186 | }
          | ^
    make: *** [Makefile:238: client.o] Error 1
    
    make failed, exit code 2
    
    Gem files will remain installed in /home/syed/.rvm/gems/ruby-2.2.2/gems/mysql2-0.3.21 for inspection.
    Results logged to /home/syed/.rvm/gems/ruby-2.2.2/extensions/x86_64-linux/2.2.0/mysql2-0.3.21/gem_make.out
    
    
    注:
    我有无法更改rails或ruby版本的限制,因为这是一个遗留项目。

    您有解决此问题的方法吗?因为我面临着同样的问题。