Mac High Sierra下如何修复OpenSSL::Digest::DSS未初始化常量问题?
Hey everyone, I just fought through a frustrating issue on my Mac High Sierra and wanted to pass along what I learned to save you some time.
I was working with Ruby gems that rely on Net::SSH, and specifically the Net::SFTP gem was failing to connect to any server. The error that kept stopping me was:
uninitialized constant OpenSSL::Digest::DSS
First thing I tried was the go-to gem update: bundle update net-ssh. I figured a newer version might patch whatever was broken, but no luck — the error persisted.
After poking around a bit, I realized this wasn't just a gem version problem. The root cause was that my Ruby installation wasn't properly linked with the system's OpenSSL library.
Here's what fixed it for me (I use rbenv, adjust these steps if you're on rvm):
- First, confirm your OpenSSL path with
which openssl— I used Homebrew's version, so mine pointed to/usr/local/bin/openssl. - Reinstall your Ruby version with explicit OpenSSL linking. For rbenv, run:
RUBY_CONFIGURE_OPTS="--with-openssl-dir=$(brew --prefix openssl)" rbenv install [your-ruby-version] - Set this freshly installed Ruby as your global or local default:
rbenv global [your-ruby-version] # Or for a project-specific setup: rbenv local [your-ruby-version] - Rebundle your dependencies with
bundle installand test Net::SFTP again.
This fixed the OpenSSL misalignment and got Net::SFTP connecting to servers without that annoying DSS constant error.
内容的提问来源于stack exchange,提问作者danielricecodes

