How to check syntax of ruby script that has script/runner as a shebang?

Joni picture Joni · Sep 12, 2011 · Viewed 16.6k times · Source

I have problems to check syntax of ruby scripts that has rails script/runner on its shebang.

Here are two example scripts and how they responses to ruby syntax checking:

Script hello_world_runner.rb:

#!/usr/bin/env script/runner
p "Hello world!"

Script hello_world.rb

#!/usr/bin/env ruby
p "Hello world!"

Here is how I try to check the syntax. First line is a command and a second line is an output.

$ ruby -c hello_world_runner.rb 
"Hello world!"

$ ruby -c hello_world.rb 
SYNTAX OK

Answer

mb14 picture mb14 · Nov 8, 2011

You can try this

tail -n +2 hellow_world_runner.rb | ruby -c

Not ideal but should work.