简体   繁体   English

无法在 Mysql Docker 容器中安装 mysql2 gem:无法构建 gem 本机扩展

[英]Cannot install mysql2 gem inside Mysql Docker container: Failed to build gem native extension

Related Github Issue: https://github.com/docker-library/mysql/issues/441相关 Github 问题: https : //github.com/docker-library/mysql/issues/441

Trying to install Sequel gem ( https://github.com/jeremyevans/sequel ) fails with "Failed to build gem native extension".尝试安装 Sequel gem ( https://github.com/jeremyevans/sequel ) 失败并显示“无法构建 gem 本机扩展”。 Docker image:码头工人形象:

FROM mysql:latest
RUN apt-get update
RUN apt-get install -y rubygems ruby-mysql2 wget build-essential libmysqlclient-dev ruby2*-dev sqlite3 libsqlite3-dev
RUN gem install mysql2 

Output:输出:

$ docker build -t "mysqltest" .
Sending build context to Docker daemon  8.704kB
Step 1/4 : FROM mysql
 ---> a8a59477268d
Step 2/4 : RUN apt-get update
 ---> Using cache
 ---> ab35c534ffcf
Step 3/4 : RUN apt-get install -y rubygems ruby-mysql2 wget build-essential libmysqlclient-dev ruby2*-dev sqlite3 libsqlite3-dev
 ---> Using cache
 ---> b703bf4ef78d
Step 4/4 : RUN gem install mysql2
 ---> Running in 79790b7f4506
Building native extensions.  This could take a while...
ERROR:  Error installing mysql2:
    ERROR: Failed to build gem native extension.

    current directory: /var/lib/gems/2.3.0/gems/mysql2-0.5.1/ext/mysql2
/usr/bin/ruby2.3 -r ./siteconf20180610-8-1ixqzle.rb extconf.rb
checking for rb_absint_size()... yes
checking for rb_absint_singlebit_p()... yes
checking for rb_wait_for_single_fd()... yes
-----
Using mysql_config at /usr/bin/mysql_config
-----
checking for mysql.h... yes
checking for errmsg.h... yes
checking for SSL_MODE_DISABLED in mysql.h... yes
checking for SSL_MODE_PREFERRED in mysql.h... yes
checking for SSL_MODE_REQUIRED in mysql.h... yes
checking for SSL_MODE_VERIFY_CA in mysql.h... yes
checking for SSL_MODE_VERIFY_IDENTITY in mysql.h... yes
checking for MYSQL.net.vio in mysql.h... yes
checking for MYSQL.net.pvio in mysql.h... no
checking for MYSQL_ENABLE_CLEARTEXT_PLUGIN in mysql.h... yes
checking for SERVER_QUERY_NO_GOOD_INDEX_USED in mysql.h... yes
checking for SERVER_QUERY_NO_INDEX_USED in mysql.h... yes
checking for SERVER_QUERY_WAS_SLOW in mysql.h... yes
checking for MYSQL_OPTION_MULTI_STATEMENTS_ON in mysql.h... yes
checking for MYSQL_OPTION_MULTI_STATEMENTS_OFF in mysql.h... yes
checking for my_bool in mysql.h... no
-----
Don't know how to set rpath on your system, if MySQL libraries are not in path mysql2 may not load
-----
-----
Setting libpath to /usr/lib/x86_64-linux-gnu
-----
creating Makefile

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

  /var/lib/gems/2.3.0/extensions/x86_64-linux/2.3.0/mysql2-0.5.1/mkmf.log

current directory: /var/lib/gems/2.3.0/gems/mysql2-0.5.1/ext/mysql2
make "DESTDIR=" clean

current directory: /var/lib/gems/2.3.0/gems/mysql2-0.5.1/ext/mysql2
make "DESTDIR="
compiling client.c
compiling infile.c
compiling mysql2_ext.c
compiling result.c
compiling statement.c
linking shared-object mysql2/mysql2.so
/usr/bin/ld: cannot find -lssl
/usr/bin/ld: cannot find -lcrypto
collect2: error: ld returned 1 exit status
Makefile:255: recipe for target 'mysql2.so' failed
make: *** [mysql2.so] Error 1

make failed, exit code 2

Gem files will remain installed in /var/lib/gems/2.3.0/gems/mysql2-0.5.1 for inspection.
Results logged to /var/lib/gems/2.3.0/extensions/x86_64-linux/2.3.0/mysql2-0.5.1/gem_make.out
The command '/bin/sh -c gem install mysql2' returned a non-zero code: 1

mkmf.log content: https://gist.github.com/ifischer/529950ce6af29280d5c778e702321b35 mkmf.log 内容: https ://gist.github.com/ifischer/529950ce6af29280d5c778e702321b35

Found the problem: I need to install default-libmysqlclient-dev instead of libmysqlclient-dev:发现问题:我需要安装default-libmysqlclient-dev而不是libmysqlclient-dev:

FROM mysql:latest
RUN apt-get update
RUN apt-get install -y rubygems ruby-mysql2 wget build-essential default-libmysqlclient-dev ruby2*-dev sqlite3 libsqlite3-dev
RUN gem install mysql2 sequel sqlite3

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

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