Sourcetree use alterative ruby

Florian Bachmann January 6, 2013

Hi, is it possible to use an alternative ruby version within sourcetree?

I need it, to use the newest version of lolcommits

Sourcetree always tries to use the system ruby Version 1.8

instead of my newly installed ruby version 1.9.3 (works fine in terminal)

here my git commit output from sourcetree:

git -c diff.mnemonicprefix=false -c core.quotepath=false commit -q -F /var/folders/yz/6ngr49dd0fv22kphv_yq_47m0000gn/T/SourceTreeTemp.bxFaJm 
/System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/lib/ruby/1.8/rubygems.rb:777:in `report_activate_error': Could not find RubyGem lolcommits (>= 0) (Gem::LoadError)
	from /System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/lib/ruby/1.8/rubygems.rb:211:in `activate'
	from /System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/lib/ruby/1.8/rubygems.rb:1056:in `gem'
	from /usr/bin/lolcommits:18
Completed successfully

2 answers

1 accepted

0 votes
Answer accepted
Florian Bachmann January 23, 2013

thanks for the hint, but editing /etc/paths and /etc/launchd.conf doesn't take effect on Mountain Lion!

Apple's Developer Forums say this:

Change the Info.plist of the .app itself to contain an "LSEnvironment" dictionary with the environment variables you want.

~/.MacOSX/environment.plist is no longer supported.

So I edit SourceTree's Info.plist (right click on "SourceTree.app" and then "Show package contents") and added a new key/dict pair called:

<key>LSEnvironment</key>
<dict>
     <key>PATH</key>
     <string>/Users/flori/.rvm/gems/ruby-1.9.3-p362/bin:/Users/flori/.rvm/gems/ruby-1.9.3-p362@global/bin:/Users/flori/.rvm/rubies/ruby-1.9.3-p326/bin:/Users/flori/.rvm/bin:/usr/bin:/bin:/usr/sbin:/sbin:/usr/local/bin:</string>
</dict>

(see: http://developer.apple.com/library/ios/#documentation/general/Reference/InfoPlistKeyReference/Articles/LaunchServicesKeys.html)

now my SourceTree App uses git 1.9.3 :-)

regards,

Flori

0 votes
stevestreeting
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
January 7, 2013

RVM is a good way to make Ruby versions co-exist cleanly, but if you don't want to do that, you'll need to make sure that all Mac apps use the new version rather than just the terminal. You've probably updated your PATH to point to the new Ruby, but this has no effect on Mac apps because they're launched by a process called 'launchd' whose environment is entirely separate from the terminal.

To update the path across the board for Mac apps too, you need to update /etc/paths and reboot. Hopefully that will solve your problem.

Suggest an answer

Log in or Sign up to answer
TAGS
AUG Leaders

Atlassian Community Events