运行脚本时如何让 xcode 使用正确版本的 ruby​​? [英] How to make xcode use the correct version of ruby when running a script?

查看:132
本文介绍了运行脚本时如何让 xcode 使用正确版本的 ruby​​?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在 xcode 中,我有一个运行 ruby​​ 脚本的运行脚本"构建阶段.但是,似乎 xcode 正在尝试使用默认的 mac 1.8 版本的 ruby​​ 而不是最新版本来运行它.鉴于脚本需要一个 gem,它失败并出现 require 错误,并且错误中的路径指向/System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/lib/ruby/1.8/rubygems/

In xcode I have a 'run script' build phase that runs a ruby script. However, it seems that xcode is trying to run it using the default mac 1.8 version of ruby rather than the latest version. Given that the script requires a gem, it's failing with a require error and the path in the error points to /System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/lib/ruby/1.8/rubygems/

显然,那条路径中的 1.8 使我怀疑.

Obviously the 1.8 in that path is making me suspicious.

如果我打开终端并运行命令 ruby -v 那么它会正确返回 2.0.0p0 我安装并使用 RVM 设置为默认值.

If I open up terminal and run the command ruby -v then it correctly returns 2.0.0p0 which I installed and set as default using RVM.

我怎样才能让 Xcode 找到正确的位置?还是我误解了这个错误?

How might I get Xcode to look in the right place? Or am I mis-interpreting this error?

更新:

为了提供更多信息,这里是编译器抛出的确切错误:

To give a little more info, here is the exact error that the compiler is throwing:

/System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/lib/ruby/1.8/rubygems/custom_require.rb:31:in `gem_original_require': no such file to load -- json (LoadError)
    from /System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/lib/ruby/1.8/rubygems/custom_require.rb:31:in `require'
from /Volumes/Macintosh HD/Documents/Projects/WesternMusicElements/WesternMusicElements/Ruby/NoteCollectionParser.rb:9
Command /bin/sh failed with exit code 1

推荐答案

您也可以执行 rvm use system 切换到默认的 mac os ruby​​,然后使用 sudo 安装 gems.对我来说似乎是最简单的.

You can also do rvm use system which switches to default mac os ruby and then install the gems with sudo. Seemed to be the easiest for me.

这篇关于运行脚本时如何让 xcode 使用正确版本的 ruby​​?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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