Sourcetree use alterative ruby

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

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

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 Join to answer
Community showcase
Brian Ganninger
Published Jan 23, 2018 in Sourcetree

Tip from the team: workflow and keyboard shortcuts

Supported Platforms macOS Sourcetree has a lot to offer and, like many developer tools, finding and using it all can be a challenge, especially for a new user. Everyone might not love ...

267 views 0 3
Read article

Atlassian User Groups

Connect with like-minded Atlassian users at free events near you!

Find a group

Connect with like-minded Atlassian users at free events near you!

Find my local user group

Unfortunately there are no AUG chapters near you at the moment.

Start an AUG

You're one step closer to meeting fellow Atlassian users at your local meet up. Learn more about AUGs

Groups near you
Atlassian Team Tour

Join us on the Team Tour

We're bringing product updates and pro tips on teamwork to ten cities around the world.

Save your spot