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

Error during installation #545

Closed
arietis opened this issue Sep 13, 2022 · 10 comments
Closed

Error during installation #545

arietis opened this issue Sep 13, 2022 · 10 comments

Comments

@arietis
Copy link

arietis commented Sep 13, 2022

I'm getting such an error when performing gem update on the arm64 based mac.

/opt/local/bin/ruby3.1 -I /opt/local/lib/ruby3.1/3.1.0 -r ./siteconf20220913-28742-hv4oe6.rb extconf.rb
checking for rb_io_maybe_wait()... yes
checking for t_open() in -lnsl... no
checking for socket() in -lsocket... no
checking for openssl/ssl.h... yes
checking for CRYPTO_malloc() in -lcrypto... yes
checking for SSL_new() in -lssl... yes
checking for LIBRESSL_VERSION_NUMBER in openssl/opensslv.h... no
checking for OpenSSL version >= 1.0.2... yes
checking for RAND_egd()... no
checking for ENGINE_load_dynamic() in openssl/engine.h... yes
checking for ENGINE_load_4758cca() in openssl/engine.h... no
checking for ENGINE_load_aep() in openssl/engine.h... no
checking for ENGINE_load_atalla() in openssl/engine.h... no
checking for ENGINE_load_chil() in openssl/engine.h... no
checking for ENGINE_load_cswift() in openssl/engine.h... no
checking for ENGINE_load_nuron() in openssl/engine.h... no
checking for ENGINE_load_sureware() in openssl/engine.h... no
checking for ENGINE_load_ubsec() in openssl/engine.h... no
checking for ENGINE_load_padlock() in openssl/engine.h... no
checking for ENGINE_load_capi() in openssl/engine.h... no
checking for ENGINE_load_gmp() in openssl/engine.h... no
checking for ENGINE_load_gost() in openssl/engine.h... no
checking for ENGINE_load_cryptodev() in openssl/engine.h... yes
checking for SSL.ctx in openssl/ssl.h... no
checking for EVP_MD_CTX_new()... yes
checking for EVP_MD_CTX_free()... yes
checking for EVP_MD_CTX_pkey_ctx()... no
checking for X509_STORE_get_ex_data()... yes
checking for X509_STORE_set_ex_data()... yes
checking for X509_STORE_get_ex_new_index()... no
checking for X509_CRL_get0_signature()... yes
checking for X509_REQ_get0_signature()... yes
checking for X509_REVOKED_get0_serialNumber()... yes
checking for X509_REVOKED_get0_revocationDate()... yes
checking for X509_get0_tbs_sigalg()... yes
checking for X509_STORE_CTX_get0_untrusted()... yes
checking for X509_STORE_CTX_get0_cert()... yes
checking for X509_STORE_CTX_get0_chain()... yes
checking for OCSP_SINGLERESP_get0_id()... yes
checking for SSL_CTX_get_ciphers()... yes
checking for X509_up_ref()... yes
checking for X509_CRL_up_ref()... yes
checking for X509_STORE_up_ref()... yes
checking for SSL_SESSION_up_ref()... yes
checking for EVP_PKEY_up_ref()... yes
checking for SSL_CTX_set_min_proto_version(NULL, 0) in openssl/ssl.h... yes
checking for SSL_CTX_get_security_level()... yes
checking for X509_get0_notBefore()... yes
checking for SSL_SESSION_get_protocol_version()... yes
checking for TS_STATUS_INFO_get0_status()... yes
checking for TS_STATUS_INFO_get0_text()... yes
checking for TS_STATUS_INFO_get0_failure_info()... yes
checking for TS_VERIFY_CTS_set_certs(NULL, NULL) in openssl/ts.h... no
checking for TS_VERIFY_CTX_set_store()... yes
checking for TS_VERIFY_CTX_add_flags()... yes
checking for TS_RESP_CTX_set_time_cb()... yes
checking for EVP_PBE_scrypt()... yes
checking for SSL_CTX_set_post_handshake_auth()... yes
checking for EVP_PKEY_check()... yes
checking for EVP_PKEY_new_raw_private_key()... yes
checking for SSL_set0_tmp_dh_pkey()... yes
checking for ERR_get_error_all()... yes
checking for TS_VERIFY_CTX_set_certs(NULL, NULL) in openssl/ts.h... no
checking for SSL_CTX_load_verify_file()... yes
checking for BN_check_prime()... yes
checking for EVP_MD_CTX_get0_md()... yes
checking for EVP_MD_CTX_get_pkey_ctx()... yes
checking for EVP_PKEY_eq()... yes
checking for EVP_PKEY_dup()... yes
creating extconf.h
creating Makefile

current directory: /opt/local/lib/ruby3.1/gems/3.1.0/gems/openssl-3.0.1/ext/openssl
make DESTDIR\= clean

current directory: /opt/local/lib/ruby3.1/gems/3.1.0/gems/openssl-3.0.1/ext/openssl
make DESTDIR\=
compiling openssl_missing.c
compiling ossl.c
ossl.c:322:21: error: implicit declaration of function 'ERR_get_error_all' is invalid in C99 [-Werror,-Wimplicit-function-declaration]
        while ((e = ERR_get_error_all(&file, &line, &func, &data, &flags))) {
                    ^
1 error generated.
make: *** [ossl.o] Error 1

make failed, exit code 2
ruby 3.1.2p20 (2022-04-12 revision 4491bb740a) [arm64-darwin21]

gem list openssl

*** LOCAL GEMS ***

openssl (default: 3.0.0)

openssl version
OpenSSL 3.0.5 5 Jul 2022 (Library: OpenSSL 3.0.5 5 Jul 2022)
@rhenium
Copy link
Member

rhenium commented Sep 13, 2022

Please attach the mkmf.log which should be generated during the update. It's the log file created by extconf.rb.

This is strange:

checking for ERR_get_error_all()... yes

extconf.rb found OpenSSL 3.0 library; ERR_get_error_all() is a new function in OpenSSL 3.0.

ossl.c:322:21: error: implicit declaration of function 'ERR_get_error_all' is invalid in C99 [-Werror,-Wimplicit-function-declaration]
while ((e = ERR_get_error_all(&file, &line, &func, &data, &flags))) {

But the actual compilation doesn't use the correct header files.

@daBee
Copy link

daBee commented Sep 17, 2022

Myself as well, same result on gem list openssl. Same version of Ruby as well.

=== OpenSSL for Ruby configurator ===
LD_LIBRARY_PATH=.:/usr/local/lib "gcc -o conftest -I/usr/local/include/ruby-3.1.0/aarch64-linux -I/usr/local/include/ruby-3.1.0/ruby/backward -I/usr/local/include/ruby-3.1.0 -I. -I/bin/openssl/include    -O3 -fno-fast-math -ggdb3 -Wall -Wextra -Wdeprecated-declarations -Wduplicated-cond -Wimplicit-function-declaration -Wimplicit-int -Wmisleading-indentation -Wpointer-arith -Wwrite-strings -Wimplicit-fallthrough=0 -Wmissing-noreturn -Wno-cast-function-type -Wno-constant-logical-operand -Wno-long-long -Wno-missing-field-initializers -Wno-overlength-strings -Wno-packed-bitfield-compat -Wno-parentheses-equality -Wno-self-assign -Wno-tautological-compare -Wno-unused-parameter -Wno-unused-value -Wsuggest-attribute=format -Wsuggest-attribute=noreturn -Wunused-variable -Wundef conftest.c  -L. -L/usr/local/lib -Wl,-rpath,/usr/local/lib -L/bin/openssl/lib -Wl,-rpath,/bin/openssl/lib -L. -fstack-protector-strong -rdynamic -Wl,-export-dynamic     -Wl,-rpath,/usr/local/lib -L/usr/local/lib -lruby-static -lz -lpthread -lrt -lrt -lgmp -ldl -lcrypt -lm   -lm  -lc"
cc1: error: /bin/openssl/include: Not a directory
cc1: note: unrecognized command-line option ‘-Wno-self-assign’ may have been intended to silence earlier diagnostics
cc1: note: unrecognized command-line option ‘-Wno-parentheses-equality’ may have been intended to silence earlier diagnostics
cc1: note: unrecognized command-line option ‘-Wno-constant-logical-operand’ may have been intended to silence earlier diagnostics
checked program was:
/* begin */
1: #include "ruby.h"
2:
3: int main(int argc, char **argv)
4: {
5:   return !!argv[argc];
6: }
/* end */

Raspberry Pi Zero 2 W.

@rhenium
Copy link
Member

rhenium commented Sep 17, 2022

@daBee It's most likely a different issue. gcc [...] -I/bin/openssl/include - this is clearly wrong. Make sure you give the correct path to --with-openssl-dir. It is the prefix where the OpenSSL is installed, not the location of the openssl executable.

@daBee
Copy link

daBee commented Sep 17, 2022

Just tried this:

[Sat Sep 17 13:32:22 user3@myzero2 ~] which openssl
/bin/openssl
[Sat Sep 17 13:32:26 user3@myzero2 ~] gem install openssl --with-openssl-dir /bin
ERROR:  While executing gem ... (Gem::OptionParser::InvalidOption)
    invalid option: --with-openssl-dir

@endlesslight0
Copy link

Having the same issue on arm64 Mac.
Installed openssl package and exported all the variables as provided by brew:

❯ brew reinstall openssl@3
❯ which ruby
/opt/homebrew/bin/ruby
❯ export LDFLAGS="-L/opt/homebrew/opt/openssl@3/lib"\n  export CPPFLAGS="-I/opt/homebrew/opt/openssl@3/include"
❯ export PKG_CONFIG_PATH="/opt/homebrew/opt/openssl@3/lib/pkgconfig"
❯ gem update
...
Results logged to /opt/homebrew/lib/ruby/gems/3.1.0/extensions/arm64-darwin-21/3.1.0/openssl-3.0.1/gem_make.out
...

Attaching the full console output and the gem_make.out
gem_update_term.log
gem_make.out.txt

@rhenium
Copy link
Member

rhenium commented Sep 20, 2022

@daBee You have to specify the "prefix" path where OpenSSL is installed. It is not the directory the openssl command line utility resides in. Anyway, your issue is completely different from OP's and we don't discuss it further in this issue. (BTW /bin/openssl is a very very unusual place to find the openssl executable. I recommend that you check if OpenSSL is installed correctly in the first place.)

@endlesslight0 It's not the same issue. Apparently, Homebrew's ruby package is built against openssl@1.1 package. I suggest removing those {LD,CPP}FLAGS and PKG_CONFIG_PATH variables and sticking to it. https://github.com/Homebrew/homebrew-core/blob/c1b0e95c0069cb2a49fac440301d0d7c8125c557/Formula/ruby.rb If you really have to use OpenSSL 3.0, the correct way to specify it is gem install openssl -- --with-openssl-dir=/opt/homebrew/opt/openssl@3 (though I don't recommend it).

@daBee
Copy link

daBee commented Sep 20, 2022

@rhenium OK, just providing information that I found. The OS might have it already installed, but I'm not sure.

@endlesslight0 If you're using homebrew ruby, you might look into .rbenv for managing all that.

@rhenium
Copy link
Member

rhenium commented Sep 20, 2022

I'm closing this issue for now. Without the log file from OP/@arietis it's not possible to tell what caused the error (and whether it was a bug in ruby/ruby-openssl or was caused by an inconsistent system configuration).

@rhenium rhenium closed this as completed Sep 20, 2022
@arietis
Copy link
Author

arietis commented Sep 20, 2022

Here is the log. mkmf.log

@rhenium
Copy link
Member

rhenium commented Sep 21, 2022

# Line 2856
-I/opt/local/include/ruby-3.1.2/arm64-darwin21
-I/opt/local/include/ruby-3.1.2/ruby/backward
-I/opt/local/include/ruby-3.1.2
-I.
-I/opt/local/libexec/openssl11/include
-isystem/opt/local/include
-isysroot/Library/Developer/CommandLineTools/SDKs/MacOSX12.sdk
-I/opt/local/include
-I/opt/local/libexec/openssl11/include
-isysroot/Library/Developer/CommandLineTools/SDKs/MacOSX12.sdk

-L.
-L/opt/local/lib
-L/opt/local/libexec/openssl11/lib
-L/opt/local/lib
-L.
-L/opt/local/libexec/openssl11/lib
-L/opt/local/lib
-L/opt/local/lib

-lssl -lcrypto  -lruby.3.1 -lssl -lcrypto

This explains it. It finds OpenSSL header files from -I/opt/local/libexec/openssl11/include and links against libcrypto/libssl from -L/opt/local/lib.

After digging a bit, mkmf.rb apparently prepends -L/opt/local/lib in order to prevent picking up a wrong libruby, but that will obviously cause the opposite effect for libcrypto/libssl.

This should be handled in Ruby's issue tracker: https://bugs.ruby-lang.org/issues/9760

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

No branches or pull requests

4 participants