无法在 macOS Ventura 上捆绑安装“mysql2”,原因是“ld:找不到 -lzlib 的库”

2023-11-21

无法安装mysql2 with bundle install。 我问这个问题是因为一些网站和博客已经展示了如何解决由ssl, zstd,但我找不到解决方案,原因是zlib。还有其他人遇到过同样的问题吗?

顺便说一下,我正在跑步bundle install在本地,而不是在码头上。

  • 操作系统:文图拉(13.3.1)
  • 代码:14.3
  • 红宝石:3.1.4
  • 导轨:6.1
  • mysql2:0.5.5

已经完成了:

  • brew install mysql, openssl@3, zstd, zlib

这是日志输出。

Fetching gem metadata from https://rubygems.org/..........
Resolving dependencies...
Using rake 13.0.6
Using concurrent-ruby 1.2.2
Using minitest 5.18.0
Using zeitwerk 2.6.8
Using websocket-extensions 0.1.5
Using erubi 1.12.0
Using racc 1.6.2
Using date 3.3.3
Using rack 2.2.7
Using bindex 0.8.1
Using bundler 2.3.26
Using marcel 1.0.2
Using mini_mime 1.1.2
Using timeout 0.3.2
Using rb-fsevent 0.11.2
Using crass 1.0.6
Using msgpack 1.7.0
Using builder 3.2.4
Using byebug 11.1.3
Using semantic_range 3.0.0
Using method_source 1.0.0
Using nio4r 2.5.9
Using spring 4.1.1
Using turbolinks-source 5.2.0
Using thor 1.2.1
Using i18n 1.13.0
Using nokogiri 1.14.3 (arm64-darwin)
Using rack-test 2.1.0
Using ffi 1.15.5
Using websocket-driver 0.7.5
Using tzinfo 2.0.6
Using sprockets 4.2.0
Using net-protocol 0.2.1
Using rack-proxy 0.7.6
Using bootsnap 1.16.0
Using puma 5.6.5
Using tilt 2.1.0
Using turbolinks 5.2.1
Using rack-mini-profiler 2.3.4
Using loofah 2.20.0
Using net-imap 0.3.4
Using net-smtp 0.3.3
Using rb-inotify 0.10.1
Using sassc 2.4.0
Using net-pop 0.1.2
Using rails-html-sanitizer 1.5.0
Using listen 3.8.0
Using activesupport 6.1.7.3
Using mail 2.8.1
Using rails-dom-testing 2.0.3
Using globalid 1.1.0
Using activemodel 6.1.7.3
Using actionview 6.1.7.3
Using activejob 6.1.7.3
Using activerecord 6.1.7.3
Using actionpack 6.1.7.3
Using jbuilder 2.11.5
Using railties 6.1.7.3
Using actioncable 6.1.7.3
Using web-console 4.2.0
Using actionmailer 6.1.7.3
Using sprockets-rails 3.4.2
Using activestorage 6.1.7.3
Using webpacker 5.4.4
Using sassc-rails 2.1.2
Using actionmailbox 6.1.7.3
Using actiontext 6.1.7.3
Using sass-rails 6.0.0
Using rails 6.1.7.3
Installing mysql2 0.5.5 with native extensions
Gem::Ext::BuildError: ERROR: Failed to build gem native extension.

    current directory: /Users/qounme/Developments/projects/templates/rails-6/vendor/bundle/ruby/3.1.0/gems/mysql2-0.5.5/ext/mysql2
/Users/qounme/.rbenv/versions/3.1.4/bin/ruby -I /Users/qounme/.rbenv/versions/3.1.4/lib/ruby/3.1.0 extconf.rb
checking for rb_absint_size()... yes
checking for rb_absint_singlebit_p()... yes
checking for rb_gc_mark_movable()... yes
checking for rb_wait_for_single_fd()... yes
checking for rb_enc_interned_str() in ruby.h... yes
-----
Using --with-openssl-dir=/Users/qounme/.rbenv/versions/3.1.4/openssl
-----
-----
Using mysql_config at /opt/homebrew/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_DEFAULT_AUTH in mysql.h... yes
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 /opt/homebrew/Cellar/mysql/8.0.33/lib
-----
creating Makefile

current directory: /Users/qounme/Developments/projects/templates/rails-6/vendor/bundle/ruby/3.1.0/gems/mysql2-0.5.5/ext/mysql2
make DESTDIR\= sitearchdir\=./.gem.20230505-8569-clyohw sitelibdir\=./.gem.20230505-8569-clyohw clean

current directory: /Users/qounme/Developments/projects/templates/rails-6/vendor/bundle/ruby/3.1.0/gems/mysql2-0.5.5/ext/mysql2
make DESTDIR\= sitearchdir\=./.gem.20230505-8569-clyohw sitelibdir\=./.gem.20230505-8569-clyohw
compiling client.c
In file included from client.c:15:
./mysql_enc_name_to_ruby.h:43:1: warning: a function declaration without a prototype is deprecated in all versions of C and is not supported in C2x [-Wdeprecated-non-prototype]
mysql2_mysql_enc_name_to_rb_hash (str, len)
^
./mysql_enc_name_to_ruby.h:86:1: warning: a function declaration without a prototype is deprecated in all versions of C and is not supported in C2x [-Wdeprecated-non-prototype]
mysql2_mysql_enc_name_to_rb (str, len)
^
2 warnings generated.
compiling infile.c
compiling mysql2_ext.c
compiling result.c
result.c:304:35: warning: implicit conversion loses integer precision: 'unsigned long' to 'int' [-Wshorten-64-to-32]
        precision = field->length - (field->decimals > 0 ? 2 : 1);
                  ~ ~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
1 warning generated.
compiling statement.c
linking shared-object mysql2/mysql2.bundle
ld: library not found for -lzlib
clang: error: linker command failed with exit code 1 (use -v to see invocation)
make: *** [mysql2.bundle] Error 1

make failed, exit code 2

Gem files will remain installed in /Users/qounme/Developments/projects/templates/rails-6/vendor/bundle/ruby/3.1.0/gems/mysql2-0.5.5 for inspection.
Results logged to /Users/qounme/Developments/projects/templates/rails-6/vendor/bundle/ruby/3.1.0/extensions/arm64-darwin-22/3.1.0/mysql2-0.5.5/gem_make.out

  /Users/qounme/.rbenv/versions/3.1.4/lib/ruby/3.1.0/rubygems/ext/builder.rb:102:in `run'
  /Users/qounme/.rbenv/versions/3.1.4/lib/ruby/3.1.0/rubygems/ext/builder.rb:51:in `block in make'
  /Users/qounme/.rbenv/versions/3.1.4/lib/ruby/3.1.0/rubygems/ext/builder.rb:43:in `each'
  /Users/qounme/.rbenv/versions/3.1.4/lib/ruby/3.1.0/rubygems/ext/builder.rb:43:in `make'
  /Users/qounme/.rbenv/versions/3.1.4/lib/ruby/3.1.0/rubygems/ext/ext_conf_builder.rb:42:in `build'
  /Users/qounme/.rbenv/versions/3.1.4/lib/ruby/3.1.0/rubygems/ext/builder.rb:171:in `build_extension'
  /Users/qounme/.rbenv/versions/3.1.4/lib/ruby/3.1.0/rubygems/ext/builder.rb:205:in `block in build_extensions'
  /Users/qounme/.rbenv/versions/3.1.4/lib/ruby/3.1.0/rubygems/ext/builder.rb:202:in `each'
  /Users/qounme/.rbenv/versions/3.1.4/lib/ruby/3.1.0/rubygems/ext/builder.rb:202:in `build_extensions'
  /Users/qounme/.rbenv/versions/3.1.4/lib/ruby/3.1.0/rubygems/installer.rb:843:in `build_extensions'
  /Users/qounme/.rbenv/versions/3.1.4/lib/ruby/3.1.0/bundler/rubygems_gem_installer.rb:72:in `build_extensions'
  /Users/qounme/.rbenv/versions/3.1.4/lib/ruby/3.1.0/bundler/rubygems_gem_installer.rb:28:in `install'
  /Users/qounme/.rbenv/versions/3.1.4/lib/ruby/3.1.0/bundler/source/rubygems.rb:207:in `install'
  /Users/qounme/.rbenv/versions/3.1.4/lib/ruby/3.1.0/bundler/installer/gem_installer.rb:54:in `install'
  /Users/qounme/.rbenv/versions/3.1.4/lib/ruby/3.1.0/bundler/installer/gem_installer.rb:16:in `install_from_spec'
  /Users/qounme/.rbenv/versions/3.1.4/lib/ruby/3.1.0/bundler/installer/parallel_installer.rb:186:in `do_install'
  /Users/qounme/.rbenv/versions/3.1.4/lib/ruby/3.1.0/bundler/installer/parallel_installer.rb:177:in `block in worker_pool'
  /Users/qounme/.rbenv/versions/3.1.4/lib/ruby/3.1.0/bundler/worker.rb:62:in `apply_func'
  /Users/qounme/.rbenv/versions/3.1.4/lib/ruby/3.1.0/bundler/worker.rb:57:in `block in process_queue'
  /Users/qounme/.rbenv/versions/3.1.4/lib/ruby/3.1.0/bundler/worker.rb:54:in `loop'
  /Users/qounme/.rbenv/versions/3.1.4/lib/ruby/3.1.0/bundler/worker.rb:54:in `process_queue'
  /Users/qounme/.rbenv/versions/3.1.4/lib/ruby/3.1.0/bundler/worker.rb:91:in `block (2 levels) in create_threads'

An error occurred while installing mysql2 (0.5.5), and Bundler cannot continue.

In Gemfile:
  mysql2

我尝试过的

・添加以下内容.zshrc做完之后brew install zlib

export LDFLAGS="-L/opt/homebrew/opt/zlib/lib"
export CPPFLAGS="-I/opt/homebrew/opt/zlib/include"
export PKG_CONFIG_PATH="/opt/homebrew/opt/zlib/lib/pkgconfig"

・添加以下内容中未显示的内容brew info zlib但在答案中提到here.

export DYLD_LIBRARY_PATH=/opt/homebrew/opt/zlib/lib:$DYLD_LIBRARY_PATH

・重新安装command line tools by xcode-select --install

Result:

  • 输出日志没有改变。
  • 无法捆绑安装mysql2

您好,要纠正相同的错误,我已经在根项目上创建了一个文件: .bundle/config 并带有此参数

---
BUNDLE_BUILD__MYSQL2: "--with-mysql-lib=/usr/local/opt/mysql/lib --with-mysql-dir=/usr/local/opt/mysql --with-mysql-config=/usr/local/opt/mysql/bin/mysql_config \ --with-mysql-include=/usr/local/opt/mysql/include --with-ldflags=-L/usr/local/opt/zlib/lib"

我认为这是最后一个 mysql brew 包的错误

我的灵感来自于https://prabinpoudel.com.np/notes/error-while-installing-mysql2-in-m1-mac/

本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)

无法在 macOS Ventura 上捆绑安装“mysql2”,原因是“ld:找不到 -lzlib 的库” 的相关文章

  • Nokogiri 本机扩展无法构建(不是 libxml2 或 libxslt 缺失问题)

    正如标题所示 它似乎并没有因为缺少 libxml2 或 libxslt 而失败 我不太确定该做什么make的错误 明白了吗 因为问题出在make期间 呵呵 无论如何 这是我得到的输出 任何想法 将不胜感激 Building native e
  • 不同 zlib 压缩级别的压缩比

    我正在考虑使用什么级别的 zlib 压缩 并且我很好奇可以在 zlib 命令中指定的不同压缩级别的不同压缩率 这zlib手册 http www zlib net manual html Constants具有以下用于指定压缩级别的常量 de
  • Heroku Gem 安装后无法使用

    我正在尝试让 heroku 在 Ubuntu 9 10 上运行 I typed sudo gem install heroku 一切正常 但是当我去跑步时 heroku list I get heroku 找不到命令 run 宝石环保看看哪
  • 在 Windows 7 x64 上的任何源中均找不到 linecache19-0.5.13

    我安装了 Ruby 如果我运行 ruby v I see ruby 1 9 3p125 2012 02 16 i386 mingw32 如果我在我的应用程序目录中运行 rails server output 31mCould not fin
  • Ruby 的所有/最佳宝石列表? [关闭]

    就目前情况而言 这个问题不太适合我们的问答形式 我们希望答案得到事实 参考资料或专业知识的支持 但这个问题可能会引发辩论 争论 民意调查或扩展讨论 如果您觉得这个问题可以改进并可能重新开放 访问帮助中心 help reopen questi
  • 如何找出 gem 捆绑包将 gem 锁定在特定版本的原因?

    我正在尝试指定一个版本节俭宝石 http rubygems org gems thrift在我的宝石文件中 gem thrift gt 0 6 0 当我尝试跑步时bundle install 我收到此错误 You have requeste
  • 如果 gem 安装不支持,本机扩展会回退到纯 Ruby

    我正在开发一个 gem 目前是纯 Ruby 但我也一直在为其中一个功能开发更快的 C 变体 该功能在纯 Ruby 中可用 但有时很慢 这种缓慢只会影响一些潜在用户 取决于他们需要哪些功能 以及他们如何使用这些功能 因此 如果 gem 无法在
  • 从 Gemfile 中找出哪些 gem 需要本机 c 扩展?

    我最近才开始将注意力转向在上面部署 Ruby 应用程序TorqueBox当然 它是构建在 Jruby 之上的 到目前为止 我基本上一直在执行bundle install然后在通往 jrubydom 的路上解决每个宝石 但我遇到了一些宝石 由
  • 为 Rails 3 应用程序制作自定义插件/gem/引擎

    我正在遵循指南http edgeguides rubyonrails org plugins html http edgeguides rubyonrails org plugins html而且它似乎有点过时了 您能看一下并告诉我哪些部分
  • 在 OS X 10.7.4 上安装 RSRuby 时找不到库

    我正在尝试在我的 Mac 上安装 RSRuby 调用后 sudo gem install rsruby 我收到此错误 ERROR Cannot find the R library aborting extconf rb failed Co
  • Bundler 似乎无法通过 Rbenv 找到正确的 Ruby

    多年来我一直使用 RVM 作为 Ruby 版本管理器 但由于其简单性 我想改用 rbenv 但是我在部署时发现了一些奇怪的问题 这似乎是错误的地方 env RBENV ROOT home deploy rbenv PATH home dep
  • Rails 注释分段错误

    有一些问题围绕着这个问题 但没有什么真正能满足我的需求 After I bundle install下面列出了我的 Gemfile 我运行annotate并出现以下错误 Users nickcoelius rvm gems ruby 1 8
  • 为什么“捆绑”会在我的开发机器上安装生产 gem?

    Gemfile 说 gem sqlite3 groups gt development test gem mysql2 group gt production 然而当我打字时bundle install在我的开发机器上安装了所有 gem 我
  • Windows 7 x64 上的 Ruby on Rails SQLite 问题

    当我尝试做的时候db create使用 Windows 7 x64 在具有此数据库配置的 sqlite 数据库上 development adapter sqlite3 database db development sqlite3 tim
  • Bundle 说 gem 丢失了 - 但事实并非如此?

    背景 我正在维护contentRuby On Rails 站点 但我确实没有 Rails 的经验 当尝试运行 Rails 服务器时 rails s我明白了 在任何来源中均找不到 activesupport 3 2 0 Run bundle
  • 在端口80启动webrick(mysql2 gem问题)

    我正在尝试让我的 webrick 在端口 80 上提供服务 我尝试过 rails server p 80 但访问被拒绝 后来我明白使用端口1 1024需要root权限 所以我尝试了这个 sudo rails server p 80 但是 现
  • ZLIB 解压缩

    我编写了一个小型应用程序 该应用程序应该解压缩以 gzip deflate 格式编码的数据 为了实现这一点 我使用 ZLIB 库 使用解压缩功能 问题是这个功能不起作用 换句话说 数据不是未压缩的 我在这里发布代码 int decompre
  • 更新系统后RubyGems错误

    使用 sudo gem update system 更新 ruby 设置后尝试启动 Rails 控制台时 我尝试通过发出以下命令来执行 Rails 控制台rails c 我收到此错误 Users myusername rvm rubies
  • 捆绑安装到开发

    由于某种原因 当我跑步时bundle install它安装到生产中 Your bundle is complete It was installed into RAILS ENV production Arrrghh 我如何切换回开发 No
  • 解压在 Python 2.5 和 Python 3.1 中腌制的数据,然后使用 zlib 解压缩

    在 Python 2 5 中 我使用以下代码存储数据 def GLWriter file name string import cPickle import zlib data zlib compress str string file o

随机推荐

  • 具有透明重定向功能的 PayPal PayFlow Pro - 用户身份验证失败问题/文档

    我在集成和查找当前文档时遇到一些困难 集成PayPal PayFlow 专业版进入我的网站 PayFlow Link 这里有一个类似的问题 https stackoverflow com questions 15808604 result
  • 在 woocommerce 中注册并重定向到登录页面时防止自动登录?

    我正在使用 woocommerce wordpress 设计一个网站 我通过参考将登录和注册页面分开这个解决方案 注册成功后 如何在未登录的情况下将注册页面重定向到登录页面 用户需要使用通过电子邮件发送的用户名和密码登录 我的登录页面是 w
  • 用于构建和查找整数范围集的数据结构

    我有一套uint32整数 集合中可能有数百万个项目 其中 50 70 是连续的 但在输入流中它们以不可预测的顺序出现 我需要 将此集合压缩为范围以实现空间有效的表示 已经使用简单的算法实现了这一点 因为仅计算一次的范围速度在这里并不重要 经
  • 如何使用非官方 Android Market API?

    我正在尝试来自的示例代码here 但我的应用程序崩溃了 我添加了日志记录 发现它崩溃了session flush 所以我删除了那条线 它不再崩溃了 但还没有达到onResult打回来 package com mytest app impor
  • XAML 中的多重绑定作为资源

    是否可以 如果是的话如何 添加多值绑定表达到资源中 我有一个多值绑定 它需要 2 个单独的绑定 并且其中一个绑定中包含转换器参数 我必须使用此绑定到 5 个不同的项目 并且这些绑定标签仅在转换器参数上有所不同 其余一切都一样 我会避免重复多
  • iPhone模拟器可以模拟打电话吗?

    我正在构建一个可以打电话的应用程序 如何在模拟器上测试此功能 我打电话时没有得到回应openURL 当然 这在实际设备上确实有效 还可以知道iPhone当前是否处于通话模式吗 对不起 朋友 您无法在模拟器上签入它 一切顺利
  • 在 R 中使用 geom_密度_2d() 时出错:“stat_密度2d()”中计算失败:带宽必须严格为正数

    在尝试使用 ggplot2 制作测试二维密度图时 我使用了代码片段 ggplot df aes x S1 x y S1 y geom point geom density 2d 我收到错误 计算失败stat density2d 带宽必须严格
  • C++:特殊化成员需要 «template<>» 语法

    我究竟做错了什么 template
  • 您如何构建 Git 存储库工作流程?

    我们已经看过并观看了有关大型分布式团队如何使用 Git 的视频 但是我们这些非分布式团队以及与团队其他成员在办公室工作的人又如何呢 我们应该如何构建我们的存储库和工作流程 想想一直使用 Subversion 或 CVS 作为单点权限的传统办
  • 在 Git 中列出冲突文件的最简单方法是什么?

    我只需要一个简单的列表矛盾的 files 还有比以下更简单的事情吗 git ls files u cut f 2 sort u or git ls files u awk print 4 sort uniq 我想我可以设置一个方便的alia
  • Bash 脚本错误 [: !=: 需要一元运算符

    在我的脚本中 我试图错误检查第一个也是唯一的参数是否等于 v 但它是一个可选参数 我用一个if声明 但我不断收到一元运算符预期错误 这是代码 if 1 v then echo usage 0 v exit fi 更具体 上面脚本的这一部分正
  • ASP.NET TextBox - 是否可以使用行内代码 <% %> 初始化文本属性

    我需要使用其他地方的属性来初始化文本框元素的文本属性 实际上我可以简单地从代码中执行此操作 但如果可以这样做会更方便
  • 如何用LocalDate查询LocalDateTime?

    我有一个类 其中包含 java time LocalDateTime 类型的属性 public class MyClass private LocalDateTime fecha 我正在使用 Spring 数据存储库 我想要完成的是根据日期
  • 使用 JSTL 如何将值“放入”HashMap

    我希望仅使用 JSTL 设置 HashMap 的键值对 这可能吗 我知道如何检索键值对 但我还没有找到设置它们的方法 任何帮助 将不胜感激 使用 JSTL 检索 HashMap 键 值对的示例
  • 在 iPhone 上查找用户文档目录的最佳方式是什么?

    我正在读艾丽卡 萨顿的书iPhone 开发者指南 并遇到了一个问题 她在书中说 找到用户的Documents目录的方法是用代码 NSHomeDirectory stringByAppendingPathComponent Documents
  • 刷新页面不丢失Post值

    页面刷新时如何维护 post 值 换句话说 如何刷新页面而不丢失 Post 值 如果没有首先提交页面 这是不可能的 除非您以某种方式将表单字段提交回服务器 即没有使用 jQuery 等进行页面刷新 某种自动保存表单脚本 如果这是为了验证检查
  • 通过 AJAX MVC 下载 Excel 文件

    我在 MVC 中有一个大的表单 我需要能够生成一个 Excel 文件 其中包含该表单子集的数据 棘手的一点是 这不应影响表单的其余部分 因此我想通过 AJAX 来完成此操作 我遇到了一些似乎相关的问题 但我不太明白答案的含义 这似乎最接近我
  • 为什么有人会使用#define 来定义常量?

    这是一个简单的问题 但为什么有人会使用 define定义常量 有什么区别 define sum 1 and const int sum 1 define有许多不同的应用程序 但您的问题似乎与一个特定的应用程序有关 定义命名常量 在 C 中很
  • 在重定向时保持 HTTP 基本身份验证处于活动状态

    我们正在使用具有基本身份验证的网络服务 一切都很顺利 直到 Web 服务的所有者实施了平衡服务 这只是将请求重定向到 Web 服务的不同实例 问题是重定向后基本身份验证失败 存在 请求身份验证凭据未通过 异常 附加信息 我们必须手动创建请求
  • 无法在 macOS Ventura 上捆绑安装“mysql2”,原因是“ld:找不到 -lzlib 的库”

    无法安装mysql2 with bundle install 我问这个问题是因为一些网站和博客已经展示了如何解决由ssl zstd 但我找不到解决方案 原因是zlib 还有其他人遇到过同样的问题吗 顺便说一下 我正在跑步bundle ins