M1 Mac에서 rbenv를 통해 Ruby 2.x, 3.x 버전 설치

14117 단어 m1rubyrails
새 M1 Mac을 구입하고 Ruby를 설치하는 데 어려움을 겪었습니다.

문제를 해결하기 위해 내가 한 일은 다음과 같습니다.

이 솔루션은 Ruby 2.6.6 및 3.0.2를 설치하는 데 효과적이었습니다.

  • 추출을 통해 설치됨anyenv
    brew install anyenv
    


  • anyenv를 통해 설치됨rbenv
    anyenv install rbenv
    


  • 그런 다음 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
    


  • 이 오류는 Openssl과 관련이 있습니다.

  • 그의 게시물은 매우 도움이되었습니다.
    https://github.com/rbenv/ruby-build/discussions/1853#discussioncomment-2146106

    Fundamentally speaking, it is caused by OpenSSL.
    [email protected] came in Sep 2021, but it was not compatible with ruby-build. So we have to switch the [email protected].





  • brew를 사용하여 openssl 버전 1.1 설치

    brew install openssl@1.1
    




  • 그런 다음 PATH를 [email protected]으로 설정합니다.

    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/[email protected]/bin' to your PATH.
    yas@MBP2 ~> exec $SHELL -l //refresh shell
    yas@MBP2 ~> which openssl
    /opt/homebrew/opt/openssl@1.1/bin/openssl
    




  • 접두사를 사용하여 Ruby 설치

    CFLAGS="-Wno-error=implicit-function-declaration" rbenv install 2.6.6
    



  • 도움이 되었기를 바랍니다

    좋은 웹페이지 즐겨찾기