This question already has an answer here:

Just upgraded to Mac OS X.9 Maverick and XeTeX (at least us used from TexWorks, which is all I've tried) now seems to be broken though it was working before. Error message when I try to typeset with ConTeXt/XeTeX:

/System/Library/Frameworks/Ruby.framework/Versions/2.0/usr/lib/ruby/2.0.0/rubygems/core_ext/kernel_require.rb:45:in 'require': /usr/local/texlive/2013/texmf-dist/scripts/context/ruby/base/switch.rb:501: invalid multibyte escape: /\xFF/ (SyntaxError) from /System/Library/Frameworks/Ruby.framework/Versions/2.0/usr/lib/ruby/2.0.0/rubygems/core_ext/kernel_require.rb:45:in 'require' from /usr/local/texlive/2013/texmf-dist/scripts/context/ruby/texexec.rb:11:in `'

Anyone else having this? Any ideas? (I'm relatively new to both TeX and Macs, as well as this site, so apologies if this is inappropriate, poorly asked or a stupid question. :) )

Edit: The problem occurs even on minimal files with both ConTeXt/XeTeX and ConTeXt/pdfTeX but not with ConTeXt/LuaTeX. Complete reinstallation of MacTeX has not helped.

marked as duplicate by Joseph Wright Jan 14 '14 at 15:23

This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.

  • 1
    I am able to typeset a simple ConTeXt document with XeConTeXt using TeXWorks on OS 10.9. So there is not a problem specifically with that combination. – Alan Munn Oct 25 '13 at 14:35

I was having the same problem. The problem is the fact that the multibyte escape '/\xFF/' is not allowed in the standard character encoding. (UTF-8?)

So to solve this problem, you have to change the file named in the error message:


I used the terminal:

sudo nano -c /usr/local/texlive/2013/texmf-dist/scripts/context/ruby/base/switch.rb

Then go to line 501 (the -c makes sure you can see the line-numbers) and change the /\xFF/ to /\x01/. In my case it did the trick!

You can see these /\xFF/'s everywhere in the ruby-codes. But context doesn't seem to need them so they don't give an error message.

  • By the looks of it, it seems to relate to arguments parsing (for which there are gems, hmm). I think it's because OSX went from ruby-1.8 straight to 2, where the whole UTF-8 handling has been revamped. The script does include a magic encoding line, but I guess the regexp's would need that specification, too. Anyway, long story short, even though your change makes it work, I don't think it's a very clean way. – morbusg Jan 8 '14 at 13:30

See (a duplicate) Unable to run ConTeXt (pdfTeX) after upgrading to Mac OS X 10.9 Mavericks.

If you upgrade MacTeX tomorrow it should apply the same patch as mentioned by Denni (and two other patches) and it should start working.

Not the answer you're looking for? Browse other questions tagged or ask your own question.