Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Install Ruby 2.2 on Mac OSX Catalina with ruby-install

Here's what I get when I try to install Ruby 2.2:

$ ruby-install ruby 2.2.10
# ...
>>> Compiling ruby 2.2.10 ...
    CC = clang
    LD = ld
    LDSHARED = clang -dynamic -bundle
    CFLAGS = -O3 -fno-fast-math -ggdb3 -Wall -Wextra -Wno-unused-parameter -Wno-parentheses -Wno-long-long -Wno-missing-field-initializers -Wunused-variable -Wpointer-arith -Wwrite-strings -Wdeclaration-after-statement -Wshorten-64-to-32 -Wimplicit-function-declaration -Wdivision-by-zero -Wdeprecated-declarations -Wextra-tokens   -pipe
    XCFLAGS = -D_FORTIFY_SOURCE=2 -fstack-protector -fno-strict-overflow -fvisibility=hidden -DRUBY_EXPORT -fPIE
    CPPFLAGS = -I/opt/X11/include -I/usr/local/opt/[email protected]/include -I/usr/local/opt/readline/include -I/usr/local/opt/libyaml/include -I/usr/local/opt/gdbm/include -D_XOPEN_SOURCE -D_DARWIN_C_SOURCE -D_DARWIN_UNLIMITED_SELECT -D_REENTRANT   -I. -I.ext/include/x86_64-darwin19 -I./include -I.
    DLDFLAGS = -Wl,-undefined,dynamic_lookup -Wl,-multiply_defined,suppress -L/usr/local/opt/[email protected]/lib -L/usr/local/opt/readline/lib -L/usr/local/opt/libyaml/lib -L/usr/local/opt/gdbm/lib  -fstack-protector -Wl,-u,_objc_msgSend -Wl,-pie -framework CoreFoundation
    SOLIBS = -lgmp
Apple clang version 12.0.0 (clang-1200.0.31.1)
Target: x86_64-apple-darwin19.6.0
Thread model: posix
InstalledDir: /Library/Developer/CommandLineTools/usr/bin
translating probes probes.d
. ./vm_opts.h
file2lastrev.rb: does not seem to be under a vcs: .
make: [.revision.time] Error 1 (ignored)
./revision.h unchanged
compiling main.c
compiling dmydln.c
compiling miniinit.c
compiling miniprelude.c
compiling array.c
compiling bignum.c
compiling class.c
compiling compar.c
compiling complex.c
compiling dir.c
compiling dln_find.c
compiling encoding.c
encoding.c:825:2: error: implicit declaration of function 'rb_str_change_terminator_length' is invalid in C99 [-Werror,-Wimplicit-function-declaration]
        rb_str_change_terminator_length(obj, oldtermlen, termlen);
        ^
1 error generated.
make: *** [encoding.o] Error 1
!!! Compiling ruby 2.2.10 failed!
  • OS Version: 10.15.6
  • ruby-install version: 0.7.1

Any ideas on how to debug or fix this? I was previously able to install other versions of 2.2 before I upgraded my OS. I'm also able to install later versions like Ruby 2.7 with no problem

like image 874
Schneems Avatar asked Sep 16 '20 19:09

Schneems


2 Answers

Apparently ignoring the compiler warning is also an option

export optflags="-Wno-error=implicit-function-declaration"

For further duscussion see Problem when installing Ruby 2.2.9 on Mac Big Sur M1

like image 110
Epigene Avatar answered Nov 15 '22 19:11

Epigene


I was able to install that version on Mac 10.15.7 using rvm.

I have [email protected] installed with homebrew. If you run brew info openssl what do you see? I would try brew upgrade openssl first.

Try running export PKG_CONFIG_PATH="/usr/local/opt/[email protected]/lib/pkgconfig" with the info brew returns. Then try rvm install 2.2.10. If that doesn't work I would try rvm install 2.2.10 --with-openssl-dir=/usr/local/opt/openssl --with-openssl-lib=/usr/local/opt/openssl/lib --with-openssl-include=/usr/local/opt/openssl/include just make sure those paths are correct for your system.

You may also need to run

export LDFLAGS="-L/usr/local/opt/[email protected]/lib"

export CPPFLAGS="-I/usr/local/opt/[email protected]/include"

beforehand, which will be supplied by brew info.

like image 21
Edward Fancher Avatar answered Nov 15 '22 21:11

Edward Fancher