无法在 Windows 上安装 ruby MySQL gem
Posted
技术标签:
【中文标题】无法在 Windows 上安装 ruby MySQL gem【英文标题】:Cannot install ruby MySQL gem on windows 【发布时间】:2021-11-13 13:24:08 【问题描述】:当我跑步时:
gem install mysql2 -- --with-mysql-lib=C:\wamp64\bin\mysql\mysql8.0.21\lib --with-mysql-include=C:\wamp64\bin\mysql\mysql8.0.21\include
我仍然收到错误:
ERROR: Error installing mysql2:
ERROR: Failed to build gem native extension.
current directory: C:/Ruby30-x64/lib/ruby/gems/3.0.0/gems/mysql2-0.5.3/ext/mysql2
C:/Ruby30-x64/bin/ruby.exe -I C:/Ruby30-x64/lib/ruby/3.0.0 -r ./siteconf20210919-5108-35pas9.rb extconf.rb --with-mysql-lib\=C:\\wamp64\\bin\\mysql\\mysql8.0.21\\lib --with-mysql-include\=C:\\wamp64\\bin\\mysql\\mysql8.0.21\\include
checking for rb_absint_size()... yes
checking for rb_absint_singlebit_p()... yes
checking for rb_wait_for_single_fd()... yes
-----
Using --with-mysql-dir=C:\wamp64\bin\mysql\mysql8.0.21
-----
checking for -lmysqlclient... yes
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...
这甚至不到总错误消息的 1%
我已经做了好几天了,我不知道该怎么办。我正在认真考虑放弃 ruby 和 rails
【问题讨论】:
【参考方案1】:试试这个https://github.com/brianmario/mysql2/issues/1005的解决方案
特别是$ bundle config --local build.mysql2 "--with-ldflags=-L/usr/local/opt/openssl/lib --with-cppflags=-I/usr/local/opt/openssl/include"
【讨论】:
【参考方案2】:我所要做的就是从 ruby 安装目录运行 msys2。生成我的 pacman 密钥并使用 mysql 连接器重试构建
【讨论】:
以上是关于无法在 Windows 上安装 ruby MySQL gem的主要内容,如果未能解决你的问题,请参考以下文章
Windows Liquid 上的 Jekyll 异常:无法获取标题
Windows / Ruby / Rails安装 - 。无法加载这样的文件--sqlite3 / sqlite3_native windows