Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to make xcode use the correct version of ruby when running a script?

Tags:

xcode

ruby

rvm

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/

Obviously the 1.8 in that path is making me suspicious.

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.

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

Update:

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
like image 201
Mark Wheeler Avatar asked Apr 02 '13 23:04

Mark Wheeler


1 Answers

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.

like image 142
Cyril Cermak Avatar answered Oct 04 '22 07:10

Cyril Cermak