8

My laptop crashed and when it rebooted, "cmd /" (toggle comment) was broken. When I try to toggle comments on a line that only contains "foo", I get this output in my code instead of "# foo":

/tmp/temp_textmate.2erfLj:68:in /bin/bash: -c: line 0: unexpected EOF while looking for matching '' /bin/bash: -c: line 1: syntax error: unexpected end of filemap' for " foo":String (NoMethodError) from /tmp/temp_textmate.2erfLj:48:in /bin/bash: -c: line 0: unexpected EOF while looking for matching'' /bin/bash: -c: line 2: syntax error: unexpected end of file'

This is driving me nuts

nannerpus
  • 1,425
  • 1
  • 12
  • 11
  • Did you try easy fixes like reinstalling TextMate? Did you try to narrow down this error, e.g. by testing "Toggle Comment" within different programming languages? More information will certainly help. – Florian Pilz Jan 05 '11 at 21:02
  • Did you ever find a solution to this problem? Just happened to me too... – Kevin Dewalt Apr 19 '11 at 13:31
  • Same issue here. Unfortunately, reinstalling did not fix. It is only happening for HTML comments though...not JS/CSS/PHP/Ruby/etc. – Matt Fordham Jun 17 '11 at 22:30
  • For anyone still having issues with this, please see my comment down below regarding the String#to_a problem. – 20man May 06 '12 at 11:40

4 Answers4

25

Matt Hayes' answer pointed me to the trouble spot.

Bundles -> Bundle Editor -> Edit Commands --> Source --> Comment Line / Selection

change line 139:

- lines = text.to_a
+ lines = text.split(/$/).map(&:chomp)

#to_a is no longer a string method.

http://ruby-doc.org/core-1.9.3/String.html

20man
  • 1,419
  • 13
  • 11
6

I ran into the same issue and figured out a workaround. Reinstalling TextMate did not help in my case.

Bundles -> Bundle Editor -> Edit Commands --> Source --> Comment Line / Selection

At the top of the script you should see this:

#!/usr/bin/env ruby

I changed this to use another installation of Ruby. In my case I'm using RVM to manage different Ruby versions, so I have:

#!/Users/_username_/.rvm/rubies/ruby-1.8.7-p334/bin/ruby

So it seems something got screwed up with the default system Ruby.

Christian Specht
  • 35,843
  • 15
  • 128
  • 182
Matt Hayes
  • 61
  • 1
  • 2
  • 2
    This for me too, but with a small change. I started getting this with the update to 10.10 Mavericks. Change: `#!/usr/bin/env ruby` to `#!/System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/bin/ruby` – Holland Nov 03 '13 at 12:02
2

I had this same problem. Reinstalling TextMate seems to have solved the problem.

This problem appeared after migrating from one Mac to another. I'm not sure if thats the cause though. They where both MacBook Pro's running snow leopard.

codr
  • 894
  • 4
  • 11
  • 17
1

If you're using ruby 2.0 or you recently upgraded to Mavericks (system ruby in Mavericks is now 2.0), edit abovementioned command and add "-Ku" to the first line, like so: #!/usr/bin/env ruby -Ku

Worked for me.

Dan S.
  • 158
  • 2
  • 11