postmodern / ruby-install

Installs Ruby, JRuby, TruffleRuby, or mruby
MIT License
1.91k stars 255 forks source link

Can't install ruby on M1 Mac "use of undeclared identifier 'RSA_SSLV23_PADDING'" #409

Closed SteveTro closed 3 years ago

SteveTro commented 3 years ago

Description

Steps To Reproduce

Steps to reproduce the bug:

  1. $ ruby-install ruby -- --with-openssl-dir=$(brew --prefix openssl)

Expected Behavior

ruby should be installed

Actual Behavior

ossl_pkey_rsa.c:950:5: error: use of undeclared identifier 'RSA_SSLV23_PADDING'
    DefRSAConst(SSLV23_PADDING);
    ^
ossl_pkey_rsa.c:885:58: note: expanded from macro 'DefRSAConst'
#define DefRSAConst(x) rb_define_const(cRSA, #x, INT2NUM(RSA_##x))
                                                         ^
<scratch space>:166:1: note: expanded from here
RSA_SSLV23_PADDING
^
110 warnings and 1 error generated.
make[2]: *** [ossl_pkey_rsa.o] Error 1
make[1]: *** [ext/openssl/all] Error 2
make: *** [build-ext] Error 2

Environment

$ ruby-install --version
ruby-install: 0.8.2
$ uname -a
Darwin macbook.fritz.box 20.3.0 Darwin Kernel Version 20.3.0: Thu Jan 21 00:06:51 PST 2021; root:xnu-7195.81.3~1/RELEASE_ARM64_T8101 arm64
$ cc --version
Apple clang version 12.0.5 (clang-1205.0.22.9)
Target: arm64-apple-darwin20.3.0
Thread model: posix
InstalledDir: /Library/Developer/CommandLineTools/usr/bin
$ openssl version
OpenSSL 3.0.0 7 sep 2021 (Library: OpenSSL 3.0.0 7 sep 2021)
superx3man commented 3 years ago

Same issue observed for intel processor as well.

postmodern commented 3 years ago

This looks like a compatibility difference between the ruby and the version of openssl. Also, - --with-openssl-dir=$(brew --prefix openssl) is not necessary, as ruby-install already passes in --with-opt-dir="$(brew --prefix openssl):$(brew --prefix readline):$(brew --prefix libyaml):$(brew --prefix gdbm)".

Can you try reproducing this without ruby-install?

$ wget https://cache.ruby-lang.org/pub/ruby/3.0/ruby-3.0.2.tar.xz
$ tar -Jvf ruby-3.0.2.tar.xz
$ cd ruby-3.0.2/
$ ./configure --with-opt-dir="$(brew --prefix openssl):$(brew --prefix readline):$(brew --prefix libyaml):$(brew --prefix gdbm)"
$ make

If manually compiling also fails, than this issue needs to be reported upstream to https://bugs.ruby-lang.org/.

hkim3162 commented 3 years ago

hey folks same issue here. on an intel (big sur 11.6) getting issues with a simple ruby-install 2.7.2 where openssl failures appear.

ossl_pkey_rsa.c:942:5: error: use of undeclared identifier 'RSA_SSLV23_PADDING'
Using chruby + ruby-install

it appears that there is some weird symlink issue. I have already tried exporting flags and paths to my /usr/bin file where homebrew installed openssl but no luck. at other times i get

  Referenced from: /Users/hkim/src/ruby-2.7.2/.ext/x86_64-darwin20/openssl.bundle
  Expected in: flat namespace

dyld: Symbol not found: _EVP_MD_type
emptyflask commented 3 years ago

I had this issue with an intel mac too. It's because homebrew now defaults openssl to openssl@3 instead of openssl@1.1

Try this:

brew install openssl@1.1
ruby-install ruby-3.0.2 -- --with-openssl-dir=$(brew --prefix openssl@1.1)
grimm26 commented 3 years ago

manual build fails, too.

---
Configuration summary for ruby version 3.0.2

   * Installation prefix: /usr/local
   * exec prefix:         ${prefix}
   * arch:                x86_64-darwin20
   * site arch:           ${arch}
   * RUBY_BASE_NAME:      ruby
   * ruby lib prefix:     ${libdir}/${RUBY_BASE_NAME}
   * site libraries path: ${rubylibprefix}/${sitearch}
   * vendor path:         ${rubylibprefix}/vendor_ruby
   * target OS:           darwin20
   * compiler:            clang -fdeclspec
   * with pthread:        yes
   * with coroutine:      amd64
   * enable shared libs:  no
   * dynamic library ext: bundle
   * CFLAGS:              ${optflags} ${debugflags} ${warnflags}
   * LDFLAGS:             -L. -fstack-protector-strong -L/usr/local/lib \
                          -L/usr/local/opt/openssl@3/lib \
                          -L/usr/local/opt/readline/lib \
                          -L/usr/local/opt/libyaml/lib \
                          -L/usr/local/opt/gdbm/lib
   * DLDFLAGS:            -Wl,-undefined,dynamic_lookup \
                          -Wl,-multiply_defined,suppress \
                          -L/usr/local/opt/openssl@3/lib \
                          -L/usr/local/opt/readline/lib \
                          -L/usr/local/opt/libyaml/lib \
                          -L/usr/local/opt/gdbm/lib
   * optflags:            -O3
   * debugflags:          -ggdb3
   * warnflags:           -Wall -Wextra -Wdeprecated-declarations \
                          -Wdivision-by-zero \
                          -Wimplicit-function-declaration -Wimplicit-int \
                          -Wmisleading-indentation -Wpointer-arith \
                          -Wshorten-64-to-32 -Wwrite-strings \
                          -Wmissing-noreturn -Wno-constant-logical-operand \
                          -Wno-long-long -Wno-missing-field-initializers \
                          -Wno-overlength-strings -Wno-parentheses-equality \
                          -Wno-self-assign -Wno-tautological-compare \
                          -Wno-unused-parameter -Wno-unused-value \
                          -Wunused-variable -Wextra-tokens
   * strip command:       strip -A -n
   * install doc:         rdoc
   * JIT support:         yes
   * man page type:       doc
   * BASERUBY -v:         ruby 2.7.3p183 (2021-04-05 revision 6847ee089d) \
                          [x86_64-darwin20]

....

ossl_pkey_rsa.c:950:5: error: use of undeclared identifier 'RSA_SSLV23_PADDING'
    DefRSAConst(SSLV23_PADDING);
    ^
ossl_pkey_rsa.c:885:58: note: expanded from macro 'DefRSAConst'
#define DefRSAConst(x) rb_define_const(cRSA, #x, INT2NUM(RSA_##x))
                                                         ^
<scratch space>:49:1: note: expanded from here
RSA_SSLV23_PADDING
^
110 warnings and 1 error generated.
make[2]: *** [ossl_pkey_rsa.o] Error 1
make[1]: *** [ext/openssl/all] Error 2
make: *** [build-ext] Error 2
grimm26 commented 3 years ago

it seems this issue is covered by https://github.com/ruby/openssl/issues/369

emptyflask commented 3 years ago

@grimm26 see my previous comment. Ruby doesn't support openssl 3 yet.

PeteHanner commented 3 years ago

After running brew uninstall openssl, brew uninstall openssl@3 and brew uninstall openssl@1.1, along with all the rm -rf suggestions along the way, I reinstalled openssl@1.1 and successfully ran ruby-install ruby-2.6.6 -- --with-openssl-dir=$(brew --prefix openssl@1.1)

dlegr250 commented 3 years ago

I had this issue with an intel mac too. It's because homebrew now defaults openssl to openssl@3 instead of openssl@1.1

Try this:

brew install openssl@1.1
ruby-install ruby-3.0.2 -- --with-openssl-dir=$(brew --prefix openssl@1.1)

I can verify that this also worked for me. Same issue, homebrew had openssl@3 installed; when I removed it and used openssl@1.1 to compile Ruby 3.0.2 it worked just fine.

postmodern commented 3 years ago

PR #410 has been merged which pins homebrew's openssl dependency to openssl@1.1. ruby-install-0.8.3 will be released shortly, then we just have to wait for homebrew to pickup the new version and for users to upgrade.

postmodern commented 3 years ago

ruby-install 0.8.3 has been released which pins the homebrew openssl dependency to openssl@1.1. Now we wait for homebrew to pull it in.

liijunwei commented 2 years ago

macos big sur

uninstall openssl@3
reinstall openssl@1.1
#open new shell
rvm reinstall "ruby-3.0.0" --with-openssl-dir=`brew --prefix openssl@1.1` --disable-binary # ok

this flow worked for me

paxperscientiam commented 2 years ago

After running brew uninstall openssl, brew uninstall openssl@3 and brew uninstall openssl@1.1, along with all the rm -rf suggestions along the way, I reinstalled openssl@1.1 and successfully ran ruby-install ruby-2.6.6 -- --with-openssl-dir=$(brew --prefix openssl@1.1)

Unfortunately, this isn't working for me (also M1 mac).

The only difference, I think, is that I'm using openssl 1.1 from macports. ruby-install ruby -- --with-openssl-dir=/opt/local/libexec/openssl11

0xjacklove commented 1 year ago

brew install openssl@1.1 export LDFLAGS="-L/opt/homebrew/opt/openssl@1.1/lib" export CPPFLAGS="-I/opt/homebrew/opt/openssl@1.1/include" ruby-install ruby-3.0.2 -- --with-openssl-dir=$(brew --prefix openssl@1.1) it works for me

AutumnChillHu commented 1 year ago

@emptyflask Thank you A LOT!!

chkhu commented 1 year ago

I had this issue with an intel mac too. It's because homebrew now defaults openssl to openssl@3 instead of openssl@1.1

Try this:

brew install openssl@1.1
ruby-install ruby-3.0.2 -- --with-openssl-dir=$(brew --prefix openssl@1.1)

This worked for me! thx🥰

sulaiman-pro commented 1 year ago

it also worked for me! thx

posiczko commented 1 year ago

FWIW, installation of legacy versions of ruby, say 2.6 or 2.7 which require openssl@1.1 may fail when openssl3 is present on a Mac. Specifying --with-openssl-dir=$(brew --prefix openssl@1.1) might not address the issue, because of how extensions detect openssl via autotools.

To fix, specify PKG_CONFIG_PATH pointing to $(brew --prefix openssl@1.1)/lib/pkgconfig which will force autotools in extensions to detect the correct path.

In addition, libffi binding may grumble of other issues, which can be fixed by setting CFLAGS to -DUSE_FFI_CLOSURE_ALLOC

In other words:

export CFLAGS="-DUSE_FFI_CLOSURE_ALLOC"
export PKG_CONFIG_PATH="$(brew --prefix openssl@1.1)/lib/pkgconfig"
ruby-install 2.6.5 -- --with-openssl-dir=$(brew --prefix openssl@1.1)
scifisamurai commented 1 year ago

I had this issue with an intel mac too. It's because homebrew now defaults openssl to openssl@3 instead of openssl@1.1

Try this:

brew install openssl@1.1
ruby-install ruby-3.0.2 -- --with-openssl-dir=$(brew --prefix openssl@1.1)

This worked on my M1 Mac as long as I uninstalled openssl@3 first ... otherwise it still failed oddly (possibly since I had /opt/homebrew/opt/openssl@3/bin in my PATH not sure ).

brew uninstall --ignore-dependencies openssl@3
ruby-install ruby-3.0.1 -- --with-openssl-dir=$(brew --prefix openssl@1.1) # I needed 3.0.1 rather than 3.0.2 but close enough
brew install openssl@3 # needed due to software already installed against openssl@3

Thank you!!

mr-liu-hunan commented 1 year ago
ruby-install 3.0.0

FWIW, installation of legacy versions of ruby, say 2.6 or 2.7 which require openssl@1.1 may fail when openssl3 is present on a Mac. Specifying --with-openssl-dir=$(brew --prefix openssl@1.1) might not address the issue, because of how extensions detect openssl via autotools.

To fix, specify PKG_CONFIG_PATH pointing to $(brew --prefix openssl@1.1)/lib/pkgconfig which will force autotools in extensions to detect the correct path.

In addition, libffi binding may grumble of other issues, which can be fixed by setting CFLAGS to -DUSE_FFI_CLOSURE_ALLOC

In other words:

export CFLAGS="-DUSE_FFI_CLOSURE_ALLOC"
export PKG_CONFIG_PATH="$(brew --prefix openssl@1.1)/lib/pkgconfig"
ruby-install 2.6.5 -- --with-openssl-dir=$(brew --prefix openssl@1.1)

很有帮助,谢谢

ziggear commented 10 months ago

mac os sonoma 14.1.2, for some other reason, I already have an openssl@3 installed in my homebrew, with an openssl@1.1 at the same time, so the comand:

rvm install 2.7.2 --with-openssl-dir=$(brew --prefix openssl@1.1)

not working for me

Then I uninstalled the openssl@3, everything is becoming OK

postmodern commented 10 months ago

@ziggear rvm is a different tool from ruby-install. ruby-install 0.9.3 should handle openssl@1.1 vs. openssl@3.

AppleCaffe commented 5 months ago
ruby-install 3.0.0

FWIW, installation of legacy versions of ruby, say 2.6 or 2.7 which require openssl@1.1 may fail when openssl3 is present on a Mac. Specifying --with-openssl-dir=$(brew --prefix openssl@1.1) might not address the issue, because of how extensions detect openssl via autotools. To fix, specify PKG_CONFIG_PATH pointing to $(brew --prefix openssl@1.1)/lib/pkgconfig which will force autotools in extensions to detect the correct path. In addition, libffi binding may grumble of other issues, which can be fixed by setting CFLAGS to -DUSE_FFI_CLOSURE_ALLOC In other words:

export CFLAGS="-DUSE_FFI_CLOSURE_ALLOC"
export PKG_CONFIG_PATH="$(brew --prefix openssl@1.1)/lib/pkgconfig"
ruby-install 2.6.5 -- --with-openssl-dir=$(brew --prefix openssl@1.1)

很有帮助,谢谢 确实这个方法是有效的。This is the key approach, thank you!