Bug report: Ruby error when running "Comment Line" in some Terraform documents

classic Classic list List threaded Threaded
2 messages Options
Reply | Threaded
Open this post in threaded view
|

Bug report: Ruby error when running "Comment Line" in some Terraform documents

Alex Chan
I’ve hit a bug when using “Comment Line” in Terraform documents,
although it only occurs on certain lines.


# Steps to reproduce

1. Install the Terraform bundle.  TextMate > Preferences > Bundles >
Terraform.

2. Create a file called "~/Desktop/example.tf" and change the document
syntax to "Terraform".

3. Enter the following contents in the file (between the '===' bars):

===
variable "aws_region" {
 default = "us-east-1"
}


===

Note that line 4 contains whitespace, although the exact whitespace
chars seem to be arbitrary.

4. Place the cursor as follows:
  a) At the start of line 1
  b) Select all of line 1
  c) Select all of line 4 (whitespace)
  d) At the start of line 4.
  After each, press ⌘+/ to Toggle Comment.


# Expected results

a/b) Line 1 will be commented out.
c/d) Line 4 will be commented out.

Note: in Terraform syntax, a comment is denoted by /* ... */


# Actual results

d) Works correctly.

All of a)-c) result in 'Failure running “Comment Line”.', with different
errors:

a) Comment Line:140:in `<main>': undefined method `to_a' for
"\u0000variable \"aws_region\" {":String (NoMethodError)
b) Comment Selection:140:in `<main>': undefined method `to_a' for
"variable \"aws_region\" {\n":String (NoMethodError)
${0:}
c) Comment Selection:140:in `<main>': undefined method `to_a' for "
\n":String (NoMethodError)
${0:}

Broadly similar – it just seemed a little odd that it doesn’t also
affect the case where your cursor is on a line containing whitespace.


# Environment

* macOS 10.12.1 (16B2657)
* TextMate version 2.0-rc.7
* ruby 2.0.0p648 (2015-12-16 revision 53162) [universal.x86_64-darwin16]

_______________________________________________
textmate mailing list
[hidden email]
http://lists.macromates.com/listinfo/textmate
Reply | Threaded
Open this post in threaded view
|

Re: Bug report: Ruby error when running "Comment Line" in some Terraform documents

Allan Odgaard-4

On 3 Mar 2017, at 3:48, Alex Chan wrote:

I’ve hit a bug when using “Comment Line” in Terraform documents,
although it only occurs on certain lines.
[…]
a) Comment Line:140:in `<main>': undefined method `to_a' for
"\u0000variable \"aws_region\" {":String (NoMethodError)

It seems that your Comment Line action is being executed by ruby 2.0, however, the shebang of this command is: #!/usr/bin/env ruby18.

I think it fails only for some lines because to_a is only used for certain code paths.

Can you double-check that you are using the stock/unmodified Comment Line action?

One way to do this would be to use ⌃⌘T then switch to Key Equivalent search and press ⌘/ — now hit “Edit” and check you get the command in the Source bundle, and that it has the ruby18 shebang.

Kind regards Allan



_______________________________________________
textmate mailing list
[hidden email]
http://lists.macromates.com/listinfo/textmate