Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Closed
SteveTro opened this issue Sep 24, 2021 · 23 comments

Comments

@SteveTro
Copy link

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)
@SteveTro SteveTro added the bug label Sep 24, 2021
@superx3man
Copy link

Same issue observed for intel processor as well.

@postmodern
Copy link
Owner

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
Copy link

hkim3162 commented Sep 24, 2021

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
Copy link
Contributor

emptyflask commented Sep 24, 2021

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
Copy link

grimm26 commented Sep 24, 2021

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
Copy link

grimm26 commented Sep 24, 2021

it seems this issue is covered by ruby/openssl#369

@emptyflask
Copy link
Contributor

emptyflask commented Sep 24, 2021

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

@PeteHanner
Copy link

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
Copy link

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
Copy link
Owner

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
Copy link
Owner

postmodern commented Sep 25, 2021

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.

templeman added a commit to templeman/dotfiles-1 that referenced this issue Sep 30, 2021
We temporarily removed the brewed versions of openssl in order to satisfy
ruby-install. See postmodern/ruby-install#409 for
details. By the time we need ruby-install again hopefully the issues with
homebrew openssl will have sorted themselves out.
@liijunwei
Copy link

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
Copy link

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
Copy link

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
Copy link

@emptyflask Thank you A LOT!!

@chkhu
Copy link

chkhu commented Jul 28, 2023

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
Copy link

it also worked for me! thx

@posiczko
Copy link

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
Copy link

scifisamurai commented Aug 17, 2023

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
Copy link

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
Copy link

ziggear commented Dec 11, 2023

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
Copy link
Owner

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

@AppleCaffe
Copy link

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!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests