Brew 更新破坏了 openssl

Brew update breaks openssl

今天我想通过 RVM 安装一个新的 Ruby 版本,但触发了自制软件更新,导致 OpenSSL 中断。

[~]$ rvm install 2.7
.
.
.
No binary rubies available for: osx/10.14/x86_64/ruby-2.7.
Continuing with compilation. Please read 'rvm help mount' to get more information on binary rubies.
Checking requirements for osx.
Updating Homebrew...
==> Homebrew has enabled anonymous aggregate formulae and cask analytics.
Read the analytics documentation (and how to opt-out) here:
  https://docs.brew.sh/Analytics

==> Auto-updated Homebrew!
Updated Homebrew from 1ea1f31d0 to c0b916764.
Updated 3 taps (homebrew/core, homebrew/cask and homebrew/services).
.
.
.
==> Upgrading 4 outdated packages:
coreutils 8.30_2 -> 8.31
libyaml 0.2.1 -> 0.2.2
openssl@1.1 1.1.1a -> 1.1.1d
readline 8.0.0 -> 8.0.1
==> Upgrading openssl@1.1 
==> Downloading https://homebrew.bintray.com/bottles/openssl@1.1-1.1.1d.mojave.bottle.tar.gz
==> Downloading from https://akamai.bintray.com/10/104ef018b7bb8fcc49f57e5a60359a28a02d480d85a959e6141394b0571cbb28?__gda__=exp=1578044774~hmac=a692626c1c5fbcfeb1077551a60292afc273163879d04dc708c6051d0fc02d5a&response-content-disposition=attachment%3Bfilename%3D%22openssl%401.1
######################################################################## 100.0%
==> Pouring openssl@1.1-1.1.1d.mojave.bottle.tar.gz
==> Caveats
A CA file has been bootstrapped using certificates from the system
keychain. To add additional certificates, place .pem files in
  /usr/local/etc/openssl@1.1/certs

and run
  /usr/local/opt/openssl@1.1/bin/c_rehash

openssl@1.1 is keg-only, which means it was not symlinked into /usr/local,
because openssl/libressl is provided by macOS so don't link an incompatible version.

If you need to have openssl@1.1 first in your PATH run:
  echo 'export PATH="/usr/local/opt/openssl@1.1/bin:$PATH"' >> ~/.bash_profile

For compilers to find openssl@1.1 you may need to set:
  export LDFLAGS="-L/usr/local/opt/openssl@1.1/lib"
  export CPPFLAGS="-I/usr/local/opt/openssl@1.1/include"

For pkg-config to find openssl@1.1 you may need to set:
  export PKG_CONFIG_PATH="/usr/local/opt/openssl@1.1/lib/pkgconfig"

==> Summary
  /usr/local/Cellar/openssl@1.1/1.1.1d: 7,983 files, 17.9MB
==> `brew cleanup` has not been run in 30 days, running now...
Removing: /usr/local/Cellar/openssl@1.1/1.1.1a... (7,953 files, 17.9MB)
Removing: /Users/MyAccount/Library/Logs/Homebrew/libdvdcss... (64B)
Pruned 0 symbolic links and 2 directories from /usr/local

当我尝试 运行 RAILS 时出现 openssl 连接错误:

[~]$ rails s
/Users/MyAccount/.rvm/rubies/ruby-x/lib/ruby/x/..../openssl.bundle: dlopen(/Users/MyAccount/.rvm/rubies/ruby-x/lib/ruby/x/..../openssl.bundle, 9): Library not loaded: /usr/local/opt/openssl/lib/libssl.1.0.0.dylib (LoadError)
  Referenced from: /Users/MyAccount/.rvm/rubies/ruby-x/lib/ruby/x/..../openssl.bundle/openssl.bundle
  Reason: image not found - /Users/MyAccount/.rvm/rubies/ruby-x/lib/ruby/x/..../openssl.bundle/openssl.bundle

brew info openssl 给我:

[~]$ brew info openssl
openssl@1.1: stable 1.1.1d (bottled) [keg-only]
Cryptography and SSL/TLS Toolkit
https://openssl.org/
/usr/local/Cellar/openssl@1.1/1.1.1a (7,953 files, 17.9MB)
  Poured from bottle on 2019-02-11 at 09:38:06
/usr/local/Cellar/openssl@1.1/1.1.1d (7,983 files, 17.9MB)
  Poured from bottle on 2020-01-03 at 15:15:16
From: https://github.com/Homebrew/homebrew-core/blob/master/Formula/openssl@1.1.rb
==> Caveats
A CA file has been bootstrapped using certificates from the system
keychain. To add additional certificates, place .pem files in
  /usr/local/etc/openssl@1.1/certs

and run
  /usr/local/opt/openssl@1.1/bin/c_rehash

openssl@1.1 is keg-only, which means it was not symlinked into /usr/local,
because openssl/libressl is provided by macOS so don't link an incompatible version.

If you need to have openssl@1.1 first in your PATH run:
  echo 'export PATH="/usr/local/opt/openssl@1.1/bin:$PATH"' >> ~/.bash_profile

For compilers to find openssl@1.1 you may need to set:
  export LDFLAGS="-L/usr/local/opt/openssl@1.1/lib"
  export CPPFLAGS="-I/usr/local/opt/openssl@1.1/include"

For pkg-config to find openssl@1.1 you may need to set:
  export PKG_CONFIG_PATH="/usr/local/opt/openssl@1.1/lib/pkgconfig"

我在 brew 中安装了两个 openssl 公式:openssl 和 openssl@1.1。其中 openssl 有版本 1.0.2q 和 openssl@1.1 版本 1.1.1a 和 1.1.1d.

在我的.bash_profile中配置了路径:

### Customize path for openssl
export PATH="/usr/local/opt/openssl@1.1/bin:$PATH"

我无法使用升级版的 openssl:无法更新 RVM,重新安装 ruby、运行 rails。我能够让它工作的唯一方法是删除

的内容
/usr/local/Cellar/openssl@1.1/1.1.1d 

并复制

的内容
/usr/local/Cellar/openssl/1.0.2q 

里面。

我怎样才能运行以正确的方式获得它?

提前致谢!!!

感谢 brew.sh 上讨论页面的帮助,我能够找到问题的原因。

brew 及其公式的自动更新不仅覆盖了 openssl@1.1 的 symlink,而且覆盖了 /usr/local/opt 中的通用 openssl link。两者现在都指向 /usr/local/Cellar/openssl@1.1,而在我的第二个开发系统上,openssl symlink 仍然指向 /usr/local/Cellar/openssl.

在我为 /usr/local/Cellar/openssl 重新创建 openssl symlink 之后,一切又恢复正常了。

上下文是 openssl 1.1 是最安全的版本,而据我所知 1.0 已被弃用。但在我的例子中,它只是维护一个开发中的遗留项目。

现在每次 brew update/upgrade 之后我还有一件事要做:验证 symlinks,在最近引入的旧版本自动清除功能已经迫使我将它们复制回我的系统来自备份。