[英]Error while trying to install mysql in Ruby on rails
Ruby version - ruby 3.1.3p185 (2022-11-24 revision 1a6b16756e) [x64-mingw-ucrt] Ruby 版本- ruby 3.1.3p185(2022-11-24 修订版 1a6b16756e)[x64-mingw-ucrt]
Rails Version - Rails 7.0.4 Rails 版本- Rails 7.0.4
Command = gem install mysql2
命令=
gem install mysql2
Error Details错误详情
Temporarily enhancing PATH for MSYS/MINGW... Using msys2 packages: mingw-w64-ucrt-x86_64-libmariadbclient Building native extensions.
暂时增强 MSYS/MINGW 的路径...使用 msys2 包:mingw-w64-ucrt-x86_64-libmariadbclient 构建本机扩展。 This could take a while... ERROR: Error installing mysql2: ERROR: Failed to build gem native extension.
这可能需要一段时间...错误:安装 mysql2 时出错:错误:无法构建 gem 本机扩展。
current directory: C:/Ruby31-x64/lib/ruby/gems/3.1.0/gems/mysql2-0.5.4/ext/mysql2
C:/Ruby31-x64/bin/ruby.exe -I C:/Ruby31-x64/lib/ruby/3.1.0 extconf.rb checking for rb_absint_size()... yes checking for rb_absint_singlebit_p()... yes checking for rb_wait_for_single_fd()... yes checking for rb_enc_interned_str() in ruby.h... yes *** extconf.rb failed *** Could not create Makefile due to some reason, probably lack of necessary libraries and/or headers.
C:/Ruby31-x64/bin/ruby.exe -I C:/Ruby31-x64/lib/ruby/3.1.0 extconf.rb 检查 rb_absint_size()... 是检查 rb_absint_singlebit_p()... 是检查对于 rb_wait_for_single_fd()... 是在 ruby.h 中检查 rb_enc_interned_str()... 是 *** extconf.rb 失败 *** 由于某种原因无法创建 Makefile,可能缺少必要的库和/或标头。 Check the mkmf.log file for more details.
检查 mkmf.log 文件以获取更多详细信息。 You may need configuration options.
您可能需要配置选项。
Provided configuration options: --with-opt-dir --without-opt-dir --with-opt-include --without-opt-include=${opt-dir}/include --with-opt-lib --without-opt-lib=${opt-dir}/lib --with-make-prog --without-make-prog --srcdir=.
提供的配置选项:--with-opt-dir --without-opt-dir --with-opt-include --without-opt-include=${opt-dir}/include --with-opt-lib -- without-opt-lib=${opt-dir}/lib --with-make-prog --without-make-prog --srcdir=. --curdir --ruby=C:/Ruby31-x64/bin/$(RUBY_BASE_NAME) --with-mysql-dir --without-mysql-dir --with-mysql-include --without-mysql-include=${mysql-dir}/include --with-mysql-lib --without-mysql-lib=${mysql-dir}/lib --with-mysql-config --without-mysql-config --with-mysqlclient-dir --without-mysqlclient-dir --with-mysqlclient-include --without-mysqlclient-include=${mysqlclient-dir}/include --with-mysqlclient-lib --without-mysqlclient-lib=${mysqlclient-dir}/lib --with-mysqlclientlib --without-mysqlclientlib C:/Ruby31-x64/lib/ruby/3.1.0/mkmf.rb:1083:in
block in find_library': undefined method
split' for nil:NilClass (NoMethodError)--curdir --ruby=C:/Ruby31-x64/bin/$(RUBY_BASE_NAME) --with-mysql-dir --without-mysql-dir --with-mysql-include --without-mysql-include=$ {mysql-dir}/include --with-mysql-lib --without-mysql-lib=${mysql-dir}/lib --with-mysql-config --without-mysql-config --with-mysqlclient-目录 --without-mysqlclient-dir --with-mysqlclient-include --without-mysqlclient-include=${mysqlclient-dir}/include --with-mysqlclient-lib --without-mysqlclient-lib=${mysqlclient- dir}/lib --with-mysqlclientlib --without-mysqlclientlib C:/Ruby31-x64/lib/ruby/3.1.0/mkmf.rb:1083:in
block in find_library': undefined method
split' for nil:NilClass (没有方法错误)paths = paths.flat_map {|path| path.split(File::PATH_SEPARATOR)} ^^^^^^ from C:/Ruby31-x64/lib/ruby/3.1.0/mkmf.rb:1083:in `each' from C:/Ruby31-x64/lib/ruby/3.1.0/mkmf.rb:1083:in `flat_map' from C:/Ruby31-x64/lib/ruby/3.1.0/mkmf.rb:1083:in `find_library' from extconf.rb:103:in `<main>'
To see why this extension failed to compile, please check the mkmf.log which can be found here:
要了解此扩展编译失败的原因,请查看可在此处找到的 mkmf.log:
C:/Ruby31-x64/lib/ruby/gems/3.1.0/extensions/x64-mingw-ucrt/3.1.0/mysql2-0.5.4/mkmf.log
C:/Ruby31-x64/lib/ruby/gems/3.1.0/extensions/x64-mingw-ucrt/3.1.0/mysql2-0.5.4/mkmf.log
extconf failed, exit code 1
extconf 失败,退出代码 1
Gem files will remain installed in C:/Ruby31-x64/lib/ruby/gems/3.1.0/gems/mysql2-0.5.4 for inspection.
Gem 文件将保留安装在 C:/Ruby31-x64/lib/ruby/gems/3.1.0/gems/mysql2-0.5.4 以供检查。 Results logged to C:/Ruby31-x64/lib/ruby/gems/3.1.0/extensions/x64-mingw-ucrt/3.1.0/mysql2-0.5.4/gem_make.out
结果记录到 C:/Ruby31-x64/lib/ruby/gems/3.1.0/extensions/x64-mingw-ucrt/3.1.0/mysql2-0.5.4/gem_make.out
This issue will resolve by installing此问题将通过安装解决
sudo apt-get install default-libmysqlclient-dev sudo apt-get install default-libmysqlclient-dev
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.