ruby-on-rails - 在 OSX catalina(10.15.1) 中使用 rbenv 安装 ruby-2.4.0 时构建失败(OS X 10.15.1 使用 ruby-build 20191124)
问题描述
我从在线论坛尝试了很多东西。但从未奏效。安装 Xcode 看看它是否有效。但事实并非如此。
起初,在安装 OpenSSL 时 C 可执行文件存在问题。但是后来我从这里发现,错误是因为安装了Anaconda。所以我卸载了anaconda并尝试再次安装。
但现在它抛出了一个不同的错误。
➜ ~ rbenv install 2.4.0 正在下载 openssl-1.1.0j.tar.gz... -> https://dqw8nmjcqpjn7.cloudfront.net/31bec6c203ce1a8e93d5994f4ed304c63ccf07676118b6634edded12ad1b3246 安装 openssl-1.1.0j... / 安装 openssl-1.0 到。用户/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:使用自制软件中的 readline
构建失败(OS X 10.15.1 使用 ruby-build 20191124)
Inspect or clean up the working tree at /var/folders/xs/gy8wglwj22g9lbhqfv9mwp7m0000gn/T/ruby-build.20191205014031.81437.0Fmlfl Results logged to /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' 内置扩展___sprintf_chk (str, 0, __darwin_obsz(str), __VA_ARGS ) ^ 190 个警告和 2 个错误生成。make[2]: * [num2int.o] Error 1 make 1 : * [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
$ 酿造 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
解决方案
首先,让您的日志修剪到重要的部分:
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__)
基本上,这表示将宏扩展到 file 中的某行时出现错误num2int.c
。那么,这个宏是从哪里来的呢?日志说宏是在文件中定义的/usr/local/include/secure/_stdio.h
。
该文件对应于本地安装的包,很可能是通过添加的brew
(它也可能已由使用包安装程序安装的某些应用程序安装,但这似乎不太可能)。我还没有找到该文件属于哪个包(我的电脑上没有它,也没有在 Google 上找到任何对它的引用),但_stdio.h
文件相当异常,所以我相信它可能与brew
's私人海湾合作委员会。然而,ruby-build
(在执行时rb-env install
)更喜欢使用 XCode 的clang
编译器,它可能不支持brew
GCC 支持的某些语法扩展。
简而言之,您最终会在 Apple 的clang
一些本地包含文件中加载使用与该编译器不兼容的某些语法的一些本地包含文件。
现在要做什么?
您必须确定该/usr/local/include/secure/
目录是否真的有用。也许,这与您不再使用的程序有关……我无法确切告诉您该怎么做,但这里有一些想法:
检查是否
secure
或secure/_stdio.h
是符号链接(即:)ls -l /usr/local/include/secure/
。如果它们是由 安装的brew
,它们应该指向下面的某个地方../Cellar/<package-name>
。如果有,也许你可以考虑卸载那个包……</p>运行
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
那里还有目录吗?
最重要的是,您现在可以通过原始构建吗?
推荐阅读
- python - 如何将 Python 结果从 SQL 服务器保存到 SQL 表中
- kubernetes - 当我尝试在工作节点中运行微服务时,我的 kubernetes 集群经常关闭
- javascript - 如何从自己的应用程序(KaiOS 功能手机)在 Facebook 上分享链接
- javascript - JavaScript,根据基数拆分字符串
- pdf.js - 如何将 externalLinkTarget 设置为 _BLANK
- mysql - 如何使用 MATCH() AGAINST() 和带有数字的字符串进行精确搜索?
- css - 如何与css一起改变文本和svg图片的颜色?
- python - 如何通过任务ID检查任务状态?
- python - spaCy 只能链接命名实体吗?
- twilio - Twilio Flex 中的保持超时 - 流