使用rbenv或rvm在Mojave OSX上安装Ruby 2.3.1 [英] Installing Ruby 2.3.1 on Mojave OSX with rbenv or rvm

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

问题描述

首先,我使用的是OSX Mojave 10.14,之前我已将其从10.13升级.我用10.13买了新的东西.

First off I am on OSX Mojave 10.14, I have previously upgraded it from 10.13. I bought it new with 10.13.

我正在尝试遵循本教程:

I am trying to follow this tutorial:

https://scotch .io/tutorials/build-a-restful-json-api-with-rails-5-part-one

我想确保使用相同版本的rails和ruby进行相同的环境设置.

I want to make sure that I have the same environment setup using the same version of rails and ruby.

当我尝试使用rbenv将我的ruby版本(当前为2.6.1)更改为2.3.1时,我使用以下命令:

When I try to use rbenv to change my version of ruby (currently 2.6.1) to 2.3.1 I use the following command:

rbenv install 2.3.1

然后出现以下错误:

file.c:23:10: fatal error: 'CoreFoundation/CFString.h' file not found

file.c:23:10: fatal error: 'CoreFoundation/CFString.h' file not found

我尝试在Internet上查找CFString.h所在的位置,并且发现了此有用的命令来列出clang搜索的目录:

I have tried looking on the internet where CFString.h might be, and I have found this useful command to list the directories where clang searches:

echo "#include <CoreFoundation/CFString.h>" | clang -v -x c -

这是输出:

$ echo "#include <CoreFoundation/CFString.h>" | clang -v -x c -
clang version 8.0.0 (tags/RELEASE_800/final)
Target: x86_64-apple-darwin18.0.0
Thread model: posix
InstalledDir: /usr/local/opt/llvm/bin
 "/usr/local/Cellar/llvm/8.0.0/bin/clang-8" -cc1 -triple x86_64-apple-macosx10.14.0 -Wdeprecated-objc-isa-usage -Werror=deprecated-objc-isa-usage -emit-obj -mrelax-all -disable-free -disable-llvm-verifier -discard-value-names -main-file-name - -mrelocation-model pic -pic-level 2 -mthread-model posix -mdisable-fp-elim -masm-verbose -munwind-tables -target-cpu penryn -dwarf-column-info -debugger-tuning=lldb -ggnu-pubnames -target-linker-version 409.12 -v -resource-dir /usr/local/Cellar/llvm/8.0.0/lib/clang/8.0.0 -fdebug-compilation-dir /Users/nfgallimore/Code/todos-api -ferror-limit 19 -fmessage-length 121 -stack-protector 1 -fblocks -fencode-extended-block-signature -fregister-global-dtors-with-atexit -fobjc-runtime=macosx-10.14.0 -fmax-type-align=16 -fdiagnostics-show-option -fcolor-diagnostics -o /var/folders/p6/pttqjn_s20g97kv6jxzwdl2m0000gn/T/--65bd40.o -x c -
clang -cc1 version 8.0.0 based upon LLVM 8.0.0 default target x86_64-apple-darwin18.0.0
#include "..." search starts here:
#include <...> search starts here:
 /usr/local/include
 /usr/local/Cellar/llvm/8.0.0/lib/clang/8.0.0/include
 /usr/include
 /System/Library/Frameworks (framework directory)
 /Library/Frameworks (framework directory)
End of search list.
<stdin>:1:10: fatal error: 'CoreFoundation/CFString.h' file not found
#include <CoreFoundation/CFString.h>
         ^~~~~~~~~~~~~~~~~~~~~~~~~~~
1 error generated.

我也不知道它是使用clang还是gcc.这是gcc的输出:

Also I am not sure if it is using clang or gcc. Here's the gcc output:

$ echo "#include <CoreFoundation/CFString.h>" | gcc -v -x c -
Apple LLVM version 10.0.0 (clang-1000.11.45.5)
Target: x86_64-apple-darwin18.0.0
Thread model: posix
InstalledDir: /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin
 "/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/clang" -cc1 -triple x86_64-apple-macosx10.14.0 -Wdeprecated-objc-isa-usage -Werror=deprecated-objc-isa-usage -emit-obj -mrelax-all -disable-free -disable-llvm-verifier -discard-value-names -main-file-name - -mrelocation-model pic -pic-level 2 -mthread-model posix -mdisable-fp-elim -fno-strict-return -masm-verbose -munwind-tables -target-cpu penryn -dwarf-column-info -debugger-tuning=lldb -target-linker-version 409.12 -v -resource-dir /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/clang/10.0.0 -fdebug-compilation-dir /Users/nfgallimore/Code/todos-api -ferror-limit 19 -fmessage-length 121 -stack-protector 1 -fblocks -fencode-extended-block-signature -fobjc-runtime=macosx-10.14.0 -fmax-type-align=16 -fdiagnostics-show-option -fcolor-diagnostics -o /var/folders/p6/pttqjn_s20g97kv6jxzwdl2m0000gn/T/--9ee343.o -x c -
clang -cc1 version 10.0.0 (clang-1000.11.45.5) default target x86_64-apple-darwin18.0.0
#include "..." search starts here:
#include <...> search starts here:
 /usr/local/include
 /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/clang/10.0.0/include
 /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/include
 /usr/include
 /System/Library/Frameworks (framework directory)
 /Library/Frameworks (framework directory)
End of search list.
<stdin>:1:10: fatal error: 'CoreFoundation/CFString.h' file not found
#include <CoreFoundation/CFString.h>
         ^~~~~~~~~~~~~~~~~~~~~~~~~~~
1 error generated.

我尝试使用以下命令重新安装xcode命令行工具:

I have tried reinstalling xcode command line tools with this command:

xcode-select --install

我还尝试使用rvm安装旧版本的ruby(2.3.1). 我遵循使用本教程在osx上安装rvm的步骤:

I have also tried to use rvm to install the older version (2.3.1) of ruby. I follow the steps for installing rvm on osx using this tutorial:

https://usabilityetc.com/articles/ruby-on-mac-os-x-with-rvm/

我安装了pgp密钥并执行curl命令来安装它:

I installed the pgp key and do the curl command to install it:

\curl -sSL https://get.rvm.io | bash -s stable --ruby

但出现以下错误:

emacs: standard input is not a tty
curl: (23) Failed writing body (0 != 2759)

因此,总而言之,我正在寻找有助于使用rbenv或rvm安装ruby 2.3.1的答案.考虑到rvm无法安装,rbenv无法找到包含文件.

So in summary, I am seeking answers that that help with installing ruby 2.3.1 using rbenv or rvm. Considering that rvm will not install and rbenv fails to find the include files.

在本教程中使用新版本的ruby似乎还不错,但我想完成本教程,而且我担心使用新版本的ruby可能会无法顺利进行.

I seem to be fine using the new version of ruby for the tutorial but I want to complete the tutorial, and I am worried that maybe something will not go smoothly using the newer version of ruby.

推荐答案

使用以下方法重新安装头文件:

Reinstall the header files with:

open /Library/Developer/CommandLineTools/Packages/macOS_SDK_headers_for_macOS_10.14.pkg

这篇关于使用rbenv或rvm在Mojave OSX上安装Ruby 2.3.1的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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