最近我将 MacOS 更新到 Monterey 12.3,其中包括 xcode 的更新。
此后我无法运行我一直在开发的 Rails 应用程序。当我尝试启动服务器时,我不断收到此错误。
我尝试过以不同的方式安装和删除 mysql。两者都使用来自mysql网站的brew安装和DMG文件。
我可以通过命令行访问数据库实例,但我认为他们的问题是我无法从应用程序连接。还有人有类似问题吗
这是完整的错误
/Users/gus/.rbenv/versions/2.6.5/lib/ruby/gems/2.6.0/gems/activesupport-6.0.3.6/lib/active_support/dependencies.rb:324:in `require': dlopen(/Users/gus/.rbenv/versions/2.6.5/lib/ruby/gems/2.6.0/gems/mysql2-0.5.3/lib/mysql2/mysql2.bundle, 0x0009): Library not loaded: libssl.1.1.dylib (LoadError)
Referenced from: /Users/gus/.rbenv/versions/2.6.5/lib/ruby/gems/2.6.0/gems/mysql2-0.5.3/lib/mysql2/mysql2.bundle
Reason: tried: 'libssl.1.1.dylib' (no such file), '/usr/local/lib/libssl.1.1.dylib' (no such file), '/usr/lib/libssl.1.1.dylib' (no such file), '/Users/gus/gus_project/Gus2021/libssl.1.1.dylib' (no such file), '/usr/local/lib/libssl.1.1.dylib' (no such file), '/usr/lib/libssl.1.1.dylib' (no such file) - /Users/gus/.rbenv/versions/2.6.5/lib/ruby/gems/2.6.0/gems/mysql2-0.5.3/lib/mysql2/mysql2.bundle
brew install [email protected]
完成所有导出路径的操作,并确保链接
[email protected]
brew link [email protected] --force
如果有人遇到这个问题,这就是解决我的问题的方法。
到
openssl
的路径需要更新。
gem install mysql2 -- --with-ldflags=-L/opt/homebrew/opt/[email protected]/lib --with-cppflags=-I/opt/homebrew/opt/[email protected]/include
bundle install
显然这是用于 openssl 安装
brew install
版本 1.1
我能够让它工作:
brew install openssl
bundle config build.mysql2 --
--with-ldflags=-L/opt/homebrew/opt/[email protected]/lib
--with-cppflags=-I/opt/homebrew/opt/[email protected]/include
我对 postgresql 也有类似的问题,运行时会出现错误
psql -d database
:
Library not loaded: '/opt/homebrew/opt/[email protected]/lib/libssl.1.1.dylib'
就我而言,我有 openssl@3 和 openssl@ 解决方案是:
brew install [email protected]
brew link [email protected] --force
然后用 homebrew 重新安装 postgresql。
我的 zshrc 也导出了以下 ENV 变量,尽管我不太确定它是否相关:
export PATH="/opt/homebrew/opt/[email protected]/bin:$PATH"
export LDFLAGS="-L/opt/homebrew/opt/[email protected]/lib"
export CPPFLAGS="-I/opt/homebrew/opt/[email protected]/include"
export PKG_CONFIG_PATH="/opt/homebrew/opt/[email protected]/lib/pkgconfig"
对于遇到和我同样问题的人!
重新安装openssh后才可以使用。然后我仔细检查了
/usr/local/opt
是否存在无效链接并修复了它们。
brew reinstall openssh