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

BUILD FAILED (OS X 10.14.6 using ruby-build 20191002-2-g786b89f) #1355

Closed
joshgoebel opened this issue Oct 3, 2019 · 12 comments
Closed

BUILD FAILED (OS X 10.14.6 using ruby-build 20191002-2-g786b89f) #1355

joshgoebel opened this issue Oct 3, 2019 · 12 comments

Comments

@joshgoebel
Copy link
Contributor

joshgoebel commented Oct 3, 2019

I'm hitting an error installing with compiling Ruby's OpenSSL stuff:

1607   │ ossl_x509cert.c:334:59: error: member reference type 'int' is not a pointer
1608   │     if (!i2a_ASN1_OBJECT(out, X509_get0_tbs_sigalg(x509)->algorithm)) {
1609   │                               ~~~~~~~~~~~~~~~~~~~~~~~~~~  ^
1610   │ ossl_x509cert.c:424:22: warning: implicit declaration of function 'X509_get0_notBefore' is invalid in C99 [-Wimplicit-function-declaration]
1611   │     if (!(asn1time = X509_get0_notBefore(x509))) {
1612   │                      ^
1613   │ ossl_x509cert.c:424:20: warning: incompatible integer to pointer conversion assigning to 'const ASN1_TIME *' (aka 'const struct asn1_string_st *') from 'int' [-Wint-conversion]
1614   │     if (!(asn1time = X509_get0_notBefore(x509))) {
1615   │                    ^ ~~~~~~~~~~~~~~~~~~~~~~~~~
1616   │ ossl_x509cert.c:443:10: warning: implicit declaration of function 'X509_set1_notBefore' is invalid in C99 [-Wimplicit-function-declaration]
1617   │     if (!X509_set1_notBefore(x509, asn1time)) {
1618   │          ^
1619   │ ossl_x509cert.c:463:22: warning: implicit declaration of function 'X509_get0_notAfter' is invalid in C99 [-Wimplicit-function-declaration]
1620   │     if (!(asn1time = X509_get0_notAfter(x509))) {
1621   │                      ^
1622   │ ossl_x509cert.c:463:20: warning: incompatible integer to pointer conversion assigning to 'const ASN1_TIME *' (aka 'const struct asn1_string_st *') from 'int' [-Wint-conversion]
1623   │     if (!(asn1time = X509_get0_notAfter(x509))) {
1624   │                    ^ ~~~~~~~~~~~~~~~~~~~~~~~~
1625   │ ossl_x509cert.c:482:10: warning: implicit declaration of function 'X509_set1_notAfter' is invalid in C99 [-Wimplicit-function-declaration]
1626   │     if (!X509_set1_notAfter(x509, asn1time)) {

Full log:

ruby-build.20191003115834.1719.log

I have OpenSSL 1.1.1d from Homebrew:

openssl@1.1: stable 1.1.1d [keg-only]

Version of ruby-build is in title. It is using "openssl from homebrew" and it is adding it to the configure options:

./configure --prefix=/Users/jgoebel/.rbenv/versions/2.6.5 --with-openssl-dir=/Users/jgoebel/.brew/opt/openssl@1.1 --with-readline-dir=/Users/jgoebel/.brew/opt/readline

Any ideas? Homebrew manages to build it's own Ruby 2.6.5 just fine, so this has got to be something funky.

@joshgoebel
Copy link
Contributor Author

joshgoebel commented Oct 3, 2019

All the Googling I did pointed to issues with not using the proper SSL and adding options like --with-openssl-dir but AFAICT it's trying to compile with SSL 1.1, and it's already passing that so I'm confused.

@joshgoebel
Copy link
Contributor Author

I resolved this by removing ~/.brew/bin and ~/.brew/sbin from my PATH and symlinking brew into ~/bin (which is still in my path). This is so that the "auto-use openssl from new" stuff still works automagically.

Now it "just works". So one of the brew binaries I have installed is breaking the install. That leaves only 226 possible culprits. Sheesh.

@joshgoebel
Copy link
Contributor Author

Ruby-build doesn't have any easy way to guarantee a sane build environment or tweak the environment or anything like that, does it?

@joshgoebel
Copy link
Contributor Author

Trying to think about how to isolate this to find out which package is the issue...

@joshgoebel
Copy link
Contributor Author

File access times... I think it's the first time in my life I've used them for anything useful:

ls -lu ~/.brew/Cellar/*/*/bin/* | grep 'Oct  4 09:4'

Damn pkg-config from Brew. Dunno what it's getting jammed up on but just brew unlink pkg-config (temporarily) fixes the build. I could probably modify it to log it's called options, but I'm about done with this, just adding this info in case anyone else has the same issue.

@mjankowski
Copy link

Thanks for all this research and (sort of weird?) fix.

I was attempting to install 2.6.5 with ruby-build (via asdf) and getting the same error re: openssl. I also had openssl 1.1 from homebrew. Unlinking pkg-config fixed the issue.

@joshgoebel
Copy link
Contributor Author

Well I do feel better that my figuring it out has helped another person. :-)

I bet it's asking pkg-config about openSSL and getting told something confusing... so it's half using OpenSSL 1.0 and half using 1.1... just a guess.

@obromios
Copy link

obromios commented Dec 5, 2019

Unlinking pgk-config worked for me. Very grateful to yyyc514, I had problems installing ruby with rvm, then tried rbenv, and finally got to this. Days in the wilderness! However, it is unclear to me what I should do after the ruby is installed. Should I relink with brew link pkg-config until I need to install another ruby?

@joshgoebel
Copy link
Contributor Author

Should I relink with brew link pkg-config until I need to install another ruby?

That's what I'd do. I imagine it's helpful for keeping the whole brew build env in sync.

@Lasvad
Copy link

Lasvad commented Dec 9, 2019

Wow! thank you guys. This also works on OSx 10.15.1 when installing ruby-2.6.5 via ruby-install. I want to make sure this comes higher in the google search. I've been having this issue for a while.

Do we need openssl@1.1 from homebrew? Do we need to relink the pkg-config? what would happen if we didn't?

Cheers guys!

@moracca
Copy link

moracca commented May 28, 2021

This thread led me to the right answer, in my case when I ran brew link --force openssl I had some messages about

Warning: Refusing to link macOS provided/shadowed software: openssl@1.1

If you need to have openssl@1.1 first in your PATH, run:
  echo 'export PATH="/usr/local/opt/openssl@1.1/bin:$PATH"' >> /Users/ldd/.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"

my system was failing to build while installing the openssl gem (I think because of a conflicting version in /opt/local/bin/openssl) and I was unable to link it fully due to the message above. I had added the LDFLAGS and CPPFLAGS, but stupidly thought the PKG_CONFIG_PATH didn't apply to me, but when I saw @joshgoebel isolated his issue to pkg-config I realized I probably needed that also. After adding PKG_CONFIG_PATH the build succeeded.

@0xdevalias
Copy link

0xdevalias commented Jun 20, 2024

The error I hit while trying to install ruby 2.7.1 (for legacy reasons) on macOS 14.4.1 (23E224) was:

..snip..

ossl_pkey_dsa.c:394:11: error: incompatible function pointer types assigning to 'int (*)(DSA *, unsigned char **)' (aka 'int (*)(struct dsa_st *, unsigned char **)') from 'int (const DSA *, unsigned char **)' (aka 'int (const struct dsa_st *, unsigned char **)') [-Wincompatible-function-pointer-types]
        i2d_func = i2d_DSA_PUBKEY;
                 ^ ~~~~~~~~~~~~~~

..snip..

78 warnings and 1 error generated.
make[2]: *** [ossl_pkey_dsa.o] Error 1
make[1]: *** [ext/openssl/all] Error 2
make: *** [build-ext] Error 2
!!! Compiling ruby 2.7.1 failed!

Based on @moracca 's solution above, I looked back through my build logs and saw this part from brew:

..snip..

openssl@1.1 is keg-only, which means it was not symlinked into /usr/local,
because this is an alternate version of another formula.

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

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"

..snip..

All those env vars except for PATH were empty in my shell, so I tried this to temporarily set them (and not impact my other installations):

export PATH="/usr/local/opt/openssl@1.1/bin:$PATH";
export LDFLAGS="-L/usr/local/opt/openssl@1.1/lib";
export CPPFLAGS="-I/usr/local/opt/openssl@1.1/include";
export PKG_CONFIG_PATH="/usr/local/opt/openssl@1.1/lib/pkgconfig";

Then tried the install again, which succeeded this time! ✅

If we wanted to, we could then cleanup the env vars again with something like:

export PATH=${PATH#/usr/local/opt/openssl@1.1/bin:}
unset LDFLAGS
unset CPPFLAGS
unset PKG_CONFIG_PATH

Or just restart our shell to get the defaults back again.

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

No branches or pull requests

6 participants