A semicolon string causes the “unterminated string to match the end of the file” in RubyMine

In the RubyMine debugger, just enter this in the clock:

';' 

or

 ";" 

and you get an error message:

 "unterminated string meets end of file" 

Why is this? This does not happen in the Rails console, and it has nothing to do with RubyMine, as far as I can tell.

+6
source share
1 answer

This is the result of a Ruby debugger that has different parsing rules from the Ruby interpreter. In fact, a regular Ruby debugger called from the irb or ruby command exhibits the same behavior. The workaround, however, is simple: create a string literal consisting of a single semicolon, just avoid it with a backslash:

 $ irb > require 'debugger' => true > debugger (rdb:1) ';' *** SyntaxError Exception: /usr/local/rvm/rubies/ruby-1.9.3-p286/lib/ruby/1.9.1/irb/context.rb:166: unterminated string meets end of file (rdb:1) '\;' ";" 

It is important to note that the Ruby debugger command line parser does not match the parser used by the irb or ruby interpreter: it is designed to parse debugger commands such as backtrace , break , etc., and not to parse the Ruby language (with shell extensions in case irb ). It has limited support for evaluating Ruby (or Ruby-style) expressions. This, of course, is crucial for efficient debugging of Ruby programs. However, you should not expect him to be able to analyze everything, that the irb or ruby team itself will be able to analyze or analyze things in exactly the same way. In some cases, like this, it can handle certain expressions, but they need to avoid obeying the rules of parsing the debugger, unlike the Ruby language itself.

The Rails console is built on top of irb and is thus a Ruby shell and respects the rules for parsing the Ruby language just like irb and ruby .

+8
source

Source: https://habr.com/ru/post/951047/


All Articles