If you’ve upgraded to ruby 1.9 (i’m currently on 1.9.1), and you use textmate, you might be getting slammed with these “invalid multibyte char” errors when running all kinds of commands. A lot of textmate bundles are actually ruby-driven, so these errors can pop up even when you’re not running commands from a ruby bundle. For example, when working on (blech) php, I use ctrl-shift-v to validate syntax all the dern time, but it was goofing with ruby 1.9.
Now this is not a permanent fix by any means — I am not a master bundle developer, and I bet a more elegant solution will be on it’s way (maybe with TextMate 2.0? heh). But quick and dirty, you can get individual commands to work by asserting UTF8 encoding at the beginning of a ruby command script. For example, the command I mention above, PHP – validate syntax, looks like this in the bundle editor (this is from the github’d bundle):
1 2 3 4 5 6 7 | #!/usr/bin/env ruby require ENV['TM_SUPPORT_PATH'] + '/lib/textmate' version = %x{#{ENV['TM_PHP'] || 'php'} -v}.split[0..2].join(' ') puts "Running syntax check with " + version + "…" result = `#{ENV['TM_PHP'] || 'php'} -d display_errors=on -l` puts result.gsub('in -', '') TextMate.go_to :line => $1 if result =~ /line (\d+)/ |
Again, broken with ruby 1.9. inserting line #2 here:
1 2 3 4 5 6 7 8 | #!/usr/bin/env ruby # encoding: utf-8 require ENV['TM_SUPPORT_PATH'] + '/lib/textmate' version = %x{#{ENV['TM_PHP'] || 'php'} -v}.split[0..2].join(' ') puts "Running syntax check with " + version + "…" result = `#{ENV['TM_PHP'] || 'php'} -d display_errors=on -l` puts result.gsub('in -', '') TextMate.go_to :line => $1 if result =~ /line (\d+)/ |
makes it work fine! again, this should be regarded as a temporary stop-gap until the bundle / textmate maintainers implement a more elegant solution (which, unfortunately, I don’t have the time to do).
cheers!
{ 2 comments… read them below or add one }
Works great. Thanks!
Perfect, saved me some frustration after starting to use ruby 1.9.2 in Textmate via rvm.