使用ruby-install在Mac OSX Catalina上安装Ruby 2.2 [英] Install Ruby 2.2 on Mac OSX Catalina with ruby-install

查看:54
本文介绍了使用ruby-install在Mac OSX Catalina上安装Ruby 2.2的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

这是我尝试安装Ruby 2.2时得到的信息:

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/openssl@1.1/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/openssl@1.1/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!

  • 操作系统版本:10.15.6
  • 红宝石安装版本:0.7.1
  • 关于如何调试或解决此问题的任何想法?在升级操作系统之前,我以前能够安装其他版本的2.2.我还可以毫无问题地安装Ruby 2.7等更高版本

    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

    推荐答案

    经过一番努力之后,我意识到错误与macOS固有的使用GCC进行编译有关,我决定进行测试.

    After a lot of breaking my head and realizing that the error has to do with the compilation using GCC that is native to macOS, I decided to do a test.

    由于旧版本的Ruby需要更新的版本中不再存在的说明,因此有必要下载Xcode的命令行工具的旧版本.

    Because older versions of Ruby need instructions that are no longer present in updated make, it is necessary to download an older version of Command Line Tools for Xcode.

    首先,使用以下命令删除您的实际版本:

    First, remove your actual version with:

    sudo rm -rf/Library/Developer/CommandLineTools

    忽略有关丢失git的错误.

    Ignore the error about missing git.

    继续 https://developer.apple.com/download/more/并下载适用于Xcode的11.x版命令行工具.

    Proceed to https://developer.apple.com/download/more/ and download 11.x version of Command Line Tools for Xcode.

    我下载了版本11.5,并且可以正常工作.运行 gcc -v

    I downloaded version 11.5 and it worked. My return when running gcc -v

    Configured with: --prefix = / Library / Developer / CommandLineTools / usr --with-gxx-include-dir = / Library / Developer / CommandLineTools / SDKs / MacOSX.sdk / usr / include / c ++ / 4.2.1
    Apple clang version 11.0.3 (clang-1103.0.32.62)
    Target: x86_64-apple-darwin19.6.0
    Thread model: posix
    InstalledDir: / Library / Developer / CommandLineTools / usr / bin
    

    要与最新的命令行12.x进行比较,您会看到类似以下内容的

    To compare, with recent Command Lines, 12.x, you'll see something like:

    Configured with: --prefix=/Applications/Xcode.app/Contents/Developer/usr --with-gxx-include-dir=/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/usr/include/c++/4.2.1
    Apple clang version 12.0.0 (clang-1200.0.32.2)
    Target: x86_64-apple-darwin19.6.0
    Thread model: posix
    InstalledDir: /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin
    

    这篇关于使用ruby-install在Mac OSX Catalina上安装Ruby 2.2的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆