Skip to content

installing older Ruby versions on OSX after XCode 12 #1489

@eddroid

Description

@eddroid

tldr: This is an installation problem and solution. Maybe ya'll can do something about this in ruby-build itself? Maybe not. In any case, it's here for the search bots.

Problem

$ rbenv install 2.1.7

output

BUILD FAILED (Mac OS X 10.15.7 using ruby-build 20200926)

Inspect or clean up the working tree at /var/folders/hk/6ghd603s4gggg2kpspf5jjth0000gn/T/ruby-build.20201110215242.31778.FSCdTL
Results logged to /var/folders/hk/6ghd603s4gggg2kpspf5jjth0000gn/T/ruby-build.20201110215242.31778.log

end of logfile output

# ruby-build.20201110215242.31778.log

3 warnings and 4 errors generated.
make[2]: *** [ossl_pkcs7.o] Error 1
make[1]: *** [ext/openssl/all] Error 2
make[1]: *** Waiting for unfinished jobs....
compiling objspace_dump.c
installing default objspace libraries
linking shared-object objspace.bundle
linking shared-object nkf.bundle
13 warnings generated.
linking shared-object date_core.bundle
make: *** [build-ext] Error 2

sample line from openssl extension MakeMakefile log:

# <BUILD_DIR>/ruby-2.1.7/ext/openssl/mkmf.log 
conftest.c:13:15: error: implicit declaration of function 'OPENSSL_cleanse' is invalid in C99 [-Werror,-Wimplicit-function-declaration]

Solution

$ CFLAGS="-Wno-error=implicit-function-declaration" rbenv install 2.1.7

output:

Downloading openssl-1.0.2u.tar.gz...
-> https://dqw8nmjcqpjn7.cloudfront.net/ecd0c6ffb493dd06707d38b14bb4d8c2288bb7033735606569d8f90f89669d16
Installing openssl-1.0.2u...
Installed openssl-1.0.2u to /Users/***/.rbenv/versions/2.1.7

Downloading ruby-2.1.7.tar.bz2...
-> https://cache.ruby-lang.org/pub/ruby/2.1/ruby-2.1.7.tar.bz2
Installing ruby-2.1.7...

WARNING: ruby-2.1.7 is past its end of life and is now unsupported.
It no longer receives bug fixes or critical security updates.

ruby-build: using readline from homebrew
Installed ruby-2.1.7 to /Users/***/.rbenv/versions/2.1.7

Explanation

XCode 12 was released September 16, 2020. Apple changed the default CFLAGS for clang.

Clang now reports an error when you use a function without an explicit declaration when building C or Objective-C code for macOS (-Werror=implicit-function-declaration flag is on).

This change prevents this version of Ruby (and possibly others) from compiling native extensions like openssl and zlib. Unfortunately, those errors only appear in the corresponding mkmf.log for the extensions.

This could also affect building some gems that use C code.

gem install <GEMNAME> -- --with-cflags="-Wno-error=implicit-function-declaration"

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions