【问题标题】:BUILD FAILED (OS X 10.15.1 using ruby-build 20191124) when installing ruby-2.4.0 with rbenv in OSX catalina(10.15.1)在 OSX catalina(10.15.1) 中使用 rbenv 安装 ruby​​-2.4.0 时构建失败(OS X 10.15.1 使用 ruby​​-build 20191124)
【发布时间】:2019-12-05 07:08:43
【问题描述】:

我从在线论坛尝试了很多东西。但从未奏效。安装 Xcode 看看它是否有效。但事实并非如此。

起初,在安装 OpenSSL 时 C 可执行文件存在问题。但是后来我从here发现,这个错误是因为安装了Anaconda。所以我卸载了anaconda并尝试再次安装。

但现在它抛出了一个不同的错误。

➜ ~ rbenv install 2.4.0 正在下载 openssl-1.1.0j.tar.gz... -> https://dqw8nmjcqpjn7.cloudfront.net/31bec6c203ce1a8e93d5994f4ed304c63ccf07676118b6634edded12ad1b3246 安装 openssl-1.1.0j... 安装 openssl-1.1.0j 到 /Users/akashpinnaka/.rbenv/versions/2.4.0

正在下载 ruby​​-2.4.0.tar.bz2... -> https://cache.ruby-lang.org/pub/ruby/2.4/ruby-2.4.0.tar.bz2 安装 ruby​​-2.4.0... ruby​​-build: 使用 homebrew 中的 readline

构建失败(OS X 10.15.1 使用 ruby​​-build 20191124)

检查或清理工作树 /var/folders/xs/gy8wglwj22g9lbhqfv9mwp7m0000gn/T/ruby-build.20191205014031.81437.0Fmlfl 结果记录到 /var/folders/xs/gy8wglwj22g9lbhqfv9mwp7m0000gn/T/ruby-build.20191205014031.81437.log

最后 10 个日志行:num2int.c:64:5:注意:匹配此 '(' sprintf(buf, "%"PRI_LL_PREFIX"u", NUM2ULL(num)); ^ /usr/local/include/secure/_stdio.h:47:27: 注意:扩展自宏 'sprintf' builtin___sprintf_chk (str, 0, __darwin_obsz(str), __VA_ARGS) ^ 产生 190 个警告和 2 个错误。 make[2]: * [num2int.o] 错误 1 ​​make1: * [ext/-test-/num2int/all] 错误 2 make: *** [build-ext] 错误 2

以前有人遇到过这个问题吗?任何帮助将不胜感激。

更新

在日志文件中添加最后几行。它们中的大多数看起来像 C 语言中的错误

/usr/local/include/stdlib.h:354:36: warning: pointer is missing a nullability type specifier (_Nonnull, _Nullable, or _Null_unspecified) [-Wnullability-completeness]
         strtouq(const char *__str, char **__endptr, int __base);
                                          ^
/usr/local/include/stdlib.h:354:36: note: insert '_Nullable' if the pointer may be null
         strtouq(const char *__str, char **__endptr, int __base);
                                          ^
                                            _Nullable 
/usr/local/include/stdlib.h:354:36: note: insert '_Nonnull' if the pointer should never be null
         strtouq(const char *__str, char **__endptr, int __base);
                                          ^
                                            _Nonnull 
/usr/local/include/stdlib.h:356:13: warning: pointer is missing a nullability type specifier (_Nonnull, _Nullable, or _Null_unspecified) [-Wnullability-completeness]
extern char *suboptarg;         /* getsubopt(3) external variable */
            ^
/usr/local/include/stdlib.h:356:13: note: insert '_Nullable' if the pointer may be null
extern char *suboptarg;         /* getsubopt(3) external variable */
            ^
              _Nullable 
/usr/local/include/stdlib.h:356:13: note: insert '_Nonnull' if the pointer should never be null
extern char *suboptarg;         /* getsubopt(3) external variable */
            ^
              _Nonnull 
num2int.c:56:21: error: expected ')'
    sprintf(buf, "%"PRI_LL_PREFIX"d", NUM2LL(num));
                    ^
num2int.c:56:5: note: to match this '('
    sprintf(buf, "%"PRI_LL_PREFIX"d", NUM2LL(num));
    ^
/usr/local/include/secure/_stdio.h:47:27: note: expanded from macro 'sprintf'
  __builtin___sprintf_chk (str, 0, __darwin_obsz(str), __VA_ARGS__)
                          ^
num2int.c:64:21: error: expected ')'
    sprintf(buf, "%"PRI_LL_PREFIX"u", NUM2ULL(num));
                    ^
num2int.c:64:5: note: to match this '('
    sprintf(buf, "%"PRI_LL_PREFIX"u", NUM2ULL(num));
    ^
/usr/local/include/secure/_stdio.h:47:27: note: expanded from macro 'sprintf'
  __builtin___sprintf_chk (str, 0, __darwin_obsz(str), __VA_ARGS__)
                          ^
190 warnings and 2 errors generated.
make[2]: *** [num2int.o] Error 1
make[1]: *** [ext/-test-/num2int/all] Error 2
make: *** [build-ext] Error 2

这里是详细错误的 pate bin: https://pastebin.com/wzLGzvC5

编辑:

$哪个叮当

/usr/bin/clang

$ brew ls

adns        gnutls      libksba     openssl     ruby
autoconf    icu4c       libtasn1    openssl@1.1 ruby-build
automake    libassuan   libtool     p11-kit     sqlite
awk     libevent    libunistring    pinentry    unbound
coreutils   libffi      libusb      pkg-config  zlib
gettext     libgcrypt   libyaml     postgresql
gmp     libgpg-error    nettle      rbenv
gnupg       libidn2     npth        readline

$ 酿造医生

Your system is ready to brew.

删除brew doctor建议的文件后

几行

$ ls -la /usr/local/include

total 0
drwxrwxr-x  270 akashpinnaka  admin  8640 Dec 24 11:30 .
drwxr-xr-x   18 root          wheel   576 Dec  5 11:15 ..
-rw-r--r--    1 akashpinnaka  admin     0 Dec  5 10:11 .keepme
lrwxr-xr-x    1 root          admin    85 Dec  5 11:21 AppleTextureEncoder.h -> /Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/include/AppleTextureEncoder.h
lrwxr-xr-x    1 root          admin    78 Dec  5 11:21 AssertMacros.h -> /Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/include/AssertMacros.h
lrwxr-xr-x    1 root          admin    78 Dec  5 11:21 Availability.h -> /Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/include/Availability.h
lrwxr-xr-x    1 root          admin    86 Dec  5 11:21 AvailabilityInternal.h -> /Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/include/AvailabilityInternal.h
lrwxr-xr-x    1 root          admin    84 Dec  5 11:21 AvailabilityMacros.h -> /Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/include/AvailabilityMacros.h
lrwxr-xr-x    1 root          admin    86 Dec  5 11:21 AvailabilityVersions.h -> /Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/include/AvailabilityVersions.h

【问题讨论】:

  • 日志文件中有什么?请将内容添加到问题中。
  • @Casper,日志文件有2000万行,我可以发最后几行
  • 添加了一些错误。
  • @Casper 添加了带有更详细错误的 pastebin
  • 我认为 Gcc 作为编译器会更可取。不是 OSX 专家,但 catalina 出了点问题。你试过这些建议了吗? github.com/rbenv/ruby-build/issues/1361

标签: ruby-on-rails ruby macos anaconda rbenv


【解决方案1】:

我遇到了类似的问题,可以推荐以下与 binutils 需要先卸载相关的方法。什么对我有用:

brew uninstall binutils
# Uninstalling /usr/local/Cellar/binutils/2.33.1... (134 files, 167.6MB)

rbenv install 2.6.5 && rbenv local 2.6.5 ;
# Downloading openssl-1.1.1d.tar.gz...
# -> https://dqw8nmjcqpjn7.cloudfront.net/1e3a91bc1f9dfce01af26026f856e064eab4c8ee0a8f457b5ae30b40b8b711f2
# Installing openssl-1.1.1d...
# Installed openssl-1.1.1d to /Users/auser/.rbenv/versions/2.6.5

# Downloading ruby-2.6.5.tar.bz2...
# -> https://cache.ruby-lang.org/pub/ruby/2.6/ruby-2.6.5.tar.bz2
# Installing ruby-2.6.5...
# ruby-build: using readline from homebrew
# Installed ruby-2.6.5 to /Users/auser/.rbenv/versions/2.6.5

在此之前,我还在 ruby-build.log 中收到了许多不同的消息 - 最后一条是:

# ld: symbol(s) not found for architecture x86_64

作为自制程序升级(卸载之前)的一部分,我采取的其他一些步骤包括:

brew install perl ruby rbenv
# // UPDATE PATHs with suggestions made by brew during install
which awk perl
# /usr/local/bin/awk
# /usr/local/bin/perl
# ^^^ IN SHORT ALL PATHs should be with /usr/local/opt OR /usr/local/bin

您可以根据需要再次重新安装 binutils,并记住使用您可能重新执行的任何未来的rbenv install 版本重复卸载(注意自己)。

PS - 在 macOS Catalina 10.15.3 (19D76) 上测试成功安装了 2.4.0 和 2.6.5

【讨论】:

  • 在尝试为 ruby​​ 2.7.1 构建 openssl 1.1.1g 时,仅删除 homebrews binutils 就为我解决了这个问题,谢谢!
【解决方案2】:

首先,让你的日志修剪到重要的部分:

num2int.c:56:21: error: expected ')'
    sprintf(buf, "%"PRI_LL_PREFIX"d", NUM2LL(num));
                    ^
num2int.c:56:5: note: to match this '('
    sprintf(buf, "%"PRI_LL_PREFIX"d", NUM2LL(num));
    ^
/usr/local/include/secure/_stdio.h:47:27: note: expanded from macro 'sprintf'
  __builtin___sprintf_chk (str, 0, __darwin_obsz(str), __VA_ARGS__)

基本上,这表示将宏扩展到文件num2int.c 中的某行时出错。那么,这个宏是从哪里来的呢?日志说宏是在文件/usr/local/include/secure/_stdio.h 中定义的。

此文件对应于本地安装的包,很可能是通过brew 添加的(它也可能由安装包安装程序的某些应用程序安装,但这似乎不太可能)。我还没有找到该文件属于哪个包(我的电脑上没有它,也没有在 Google 上找到任何对它的引用),但 _stdio.h 文件是相当特殊的,所以我相信它可能是相关的到brew 的私人 GCC。然而,ruby-build(通过 rb-env install 执行时)更喜欢使用 XCode 的 clang 编译器,它可能不支持 brew 的 GCC 支持的某些语法扩展。

简而言之,您最终会在 Apple 的 clang 中加载一些使用与该编译器不兼容的语法的本地包含文件。

现在该怎么办?

您必须确定/usr/local/include/secure/ 目录是否真的有用。也许,这与您不再使用的程序有关……我无法确切告诉您该怎么做,但这里有一些想法:

  • 检查 securesecure/_stdio.h 是否是符号链接(即:ls -l /usr/local/include/secure/)。如果它们是由brew 安装的,它们应该指向../Cellar/<package-name> 下的某个位置。如果有,也许你可以考虑卸载那个包……

  • 运行brew doctor 并检查“意外的头文件”。

理想情况下,您希望最终删除该目录...如果您不确定这是一个好主意,那么您可以考虑将其暂时移出include 目录,例如通过执行以下操作:

mkdir /usr/local/include.disabled
mv /usr/local/include/secure /usr/local/include.disabled/secure

# Compile ruby

mv /usr/local/include.disabled/secure /usr/local/include/secure
rm -rf /usr/local/include.disabled

如果这些都不起作用,请将以下命令的输出发布到 pastebin:

which clang

brew doctor

brew ls

ls -la /usr/local/include

如何将所有 OSX SDK 包含文件移出local/include

我认为以下命令应该足以将所有指向 OSX SDK 的包含文件移出 /usr/local/include 目录(我在这里的不确定性与子目录本身是否被符号链接有关,或者它是否是这些是符号链接的子目录……我假设是第一个,如果它们是第二种类型,这个 oneliner 脚本将丢失目录)。

mkdir -p /usr/local/include.disabled/
find /usr/local/include/ -depth 1 -lname '/Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/*' -exec mv '{}' /usr/local/include.disabled/ ';'

运行这些命令,然后再次执行ls -la /usr/local/include……里面的内容应该少很多。你那里还有secure 目录吗?

最重要的是,您现在可以完成原始构建吗?

【讨论】:

  • 发现了一些非常有趣的东西……在同一个文件的同一行发现了这个 7 岁的 gist 和相同的错误(除了它在 /usr/include/secure,而不是 local):@ 987654321@。这让我觉得你可能在/src/local/include/ 下有一个来自 Apple 的一些非常旧的头文件的副本……难道你还安装了一些 brew 的apple-gcc* 公式?
  • 我认为第二个“mv”命令应该将“secure”目录复制回原来的位置,但没有。
  • 确实...已修复!
  • 感谢@jwatkins 的回复。我用你问的细节更新了问题
  • 你救了我的命@jwatkins。我的问题是移出此文件夹后 /usr/local/include 上的符号链接。一切正常。谢谢
【解决方案3】:

你能尝试运行这些命令吗:

brew unlink gawk
brew reinstall awk
awk

运行前rbenv install 2.4.0

【讨论】:

  • 试过了。还是同样的错误。当我brew unlink gawk 时,它说Error: No such keg: /usr/local/Cellar/gawk。感谢回复
  • 这里一样 - 不起作用 (Error: No such keg: /usr/local/Cellar/gawk)
  • 可能问题出在您的本地 brew 安装上,请您尝试此修复:stackoverflow.com/questions/28225045/…@iKK
猜你喜欢
  • 2020-01-21
  • 1970-01-01
  • 1970-01-01
  • 2013-11-05
  • 1970-01-01
  • 1970-01-01
  • 2021-01-03
  • 2020-04-16
相关资源
最近更新 更多