Skip to content


Subversion checkout URL

You can clone with
Download ZIP

Troubleshooting MacRuby

ferrous26 edited this page · 10 revisions

Hi all, I'm dying to know how to:


Sometimes it is possible that the back trace for other exceptions can get lost. This may be a result of MacRuby Ticket #1369, but it might also be because of MacRuby Ticket #1320 or perhaps some freedom patch in a library that you are using or have added yourself.

As the bug reports have outlined, the loss of back trace happens for multiple exception classes. There is a work around until the issue is properly addressed.

Disabling Compiled Code

Back traces can be lost for reasons other than a bug. When using compiled MacRuby code, you cannot get a Ruby level back trace in case of an error. Having Ruby level backtraces for compiled code is a feature that has not yet been implemented.

In the mean time, if you suspect that the portion of a back trace that would come from a compiled file is the problem, then you can disable loading compiled files which will force MacRuby to load source ruby files instead. You can disable loading compiled files by setting the VM_DISABLE_RBO environment variable before running a script. You can disable loading for a single session like so:

VM_DISABLE_RBO=1 macruby my_script.rb

Disable the Garbage Collector

Sometimes you may be hitting a bug related to garbage collection. For instance, a write barrier might be missing somewhere, which indirectly results in an object being prematurely collected, and by later a crash when trying to access the object in question.

To investigate this type of bugs, it can be handy to run your code with the garbage collection disabled.

GC_DISABLE=1 macruby my_script.rb

Disable the JIT optimization

It is known that JIT optimization might take a long time. Sometimes you may load the RubyGems which is using many files. And loading might be too slowly.

To disable the JIT optimization, might improve the loading time.

VM_OPT_LEVEL=0 macruby my_script.rb

In addition, if your problem is not produced when you apply the VM_OPT_LEVEL=0, it might be a bug related to JIT compiler.

Using Xcode

You can set environment variables in Xcode by going to Product --> Edit Schemes. Add your variables in the Arguments tab.

Other Options

Other debugging options are also available from MacRuby itself. You should check out Hacking.rdoc in the MacRuby source repository for more details.

Don't Be Afraid To Ask Questions Or Log Bugs

Sometimes your problem will be a MacRuby problem and the best way to get it fixed is to send an email to the mailing list, log a bug, or talk to someone in the #macruby IRC channel.

Something went wrong with that request. Please try again.