Buy @ Amazon

Debugging Shebang

Coding is eternal fun and learning exercise. Take the case of an example code snippet below that I tried to run like $ ./debugging_shebang.rb in the command line and it threw an error like -bash: puts: command not found

What do you think is the issue?

My first attempt was to execute the script with a ruby command in command line as in $ ruby ./debugging_shebang.rb and bingo the command-line echoed Hi there!. That implied the ruby code had no error and that ruby was pretty much in the environment PATH of the terminal.

Could the syntax of Shebang be wrong? A quick googling revealed that the syntax is indeed right.

Diving into stackoverflow, I learned that the file most likely did not have execute permission causing the error, which was spot-on in my case. Like the wise man suggested, changing the file permission to have execution rights solved the issue.

Lesson learnt and it feels good to quickly resolve an issue!

Also it wows me to realize, "What an impact stackoverflow-community makes in the realm of learning!".