I bought new M1 Mac and struggled to install Ruby.
Here’s what I did to solve the issue.
This solution worked for me installing Ruby 2.6.6 and 3.0.2.
-
Installed
anyenv
via brew
brew install anyenv
-
Installed
rbenv
via anyenv
anyenv install rbenv
-
Then I got an error while installing Ruby
rbenv install 2.6.6
rbenv install 2.6.6 Downloading openssl-1.1.1q.tar.gz... -> https://dqw8nmjcqpjn7.cloudfront.net/d7939ce614029cdff0b6c20f0e2e5703158a489a72b2507b8bd51bf8c8fd10ca Installing openssl-1.1.1q... BUILD FAILED (macOS 12.3 using ruby-build 20220630-3-g2155888) Inspect or clean up the working tree at /var/folders/7w/__wt6xg10rv3jdq_z2rjt8300000gn/T/ruby-build.20220706155948.38261.B1lwKj Results logged to /var/folders/7w/__wt6xg10rv3jdq_z2rjt8300000gn/T/ruby-build.20220706155948.38261.log Last 10 log lines: clang -Iinclude -arch arm64 -O3 -Wall -D_REENTRANT -DZLIB -DZLIB_SHARED -DNDEBUG -I/Users/yas/.anyenv/envs/rbenv/versions/2.6.6/include -MMD -MF test/wpackettest.d.tmp -MT test/wpackettest.o -c -o test/wpackettest.o test/wpackettest.c clang -Iinclude -arch arm64 -O3 -Wall -D_REENTRANT -DZLIB -DZLIB_SHARED -DNDEBUG -I/Users/yas/.anyenv/envs/rbenv/versions/2.6.6/include -MMD -MF test/x509_check_cert_pkey_test.d.tmp -MT test/x509_check_cert_pkey_test.o -c -o test/x509_check_cert_pkey_test.o test/x509_check_cert_pkey_test.c test/v3ext.c:201:24: error: implicitly declaring library function 'memcmp' with type 'int (const void *, const void *, unsigned long)' [-Werror,-Wimplicit-function-declaration] if (!TEST_true(memcmp(ip1->data, ip2->data, ip1->length) <= 0)) ^ test/v3ext.c:201:24: note: include the header <string.h> or explicitly provide a declaration for 'memcmp' 1 error generated. make[1]: *** [test/v3ext.o] Error 1 make[1]: *** Waiting for unfinished jobs.... make: *** [all] Error 2
-
This error is related to Openssl
-
His post was so helpful.
https://github.com/rbenv/ruby-build/discussions/1853#discussioncomment-2146106Fundamentally speaking, it is caused by OpenSSL.
OpenSSL@3.0 came in Sep 2021, but it was not compatible with ruby-build. So we have to switch the OpenSSL@1.1.
-
-
Installed openssl version 1.1 using brew
brew install openssl@1.1
-
Then set PATH to openssl@1.1
yas@MBP2 ~> which openssl /usr/bin/openssl yas@MBP2 ~> fish_add_path /opt/homebrew/opt/openssl@1.1/bin // set PATH. this is for fish shell. // if you use other than fish, add '/opt/homebrew/opt/openssl@1.1/bin' to your PATH. yas@MBP2 ~> exec $SHELL -l //refresh shell yas@MBP2 ~> which openssl /opt/homebrew/opt/openssl@1.1/bin/openssl
-
Install Ruby using a prefix
CFLAGS="-Wno-error=implicit-function-declaration" rbenv install 2.6.6
Hope this helps
Top comments (9)
I just created an account to Thank You!! :)
Thank you Ryan! I'm happy that I could help you!
I'm lost trying to install ruby versions using rbenv. Might you have a bit of time to help me troubleshoot? I've tried what's here but am experiencing a different set of issues related to the clang compiler
Why not 2.7? 2.6 got EOL'd early this year.
Thanks for telling!
My company product is running on 2.6 now, so I had no choice :-(
🤔 Use 2.7 or higher very soon in your company!
Got it! I'm gonna suggest it to my team.😊
That's also what I doing for replace my M1 macbook air from INTEL to Apple base, thanks!
Good to know!
Thanks for your feedback!