Added shebang but it doesn't work
20 Apr 2012, 16:24
Leonel Santos (11 posts)
I added this shebang as the very first line of the file #!/usr/bin/env
I go to the directory where the rb file is located and then run todo.rb and get error “todo.rb: command not found”.
So I went directly to the /usr/bin directory. I found the env command and ran it. The output of the env command displays ruby paths and ruby data, like this…
So since, I couldn’t make it work, I changed the shebang to point to ruby directly: #!/home/tallercreativo/.rvm/rubies/ruby-1.9.2-p290/bin/ruby
and I get same command not found error.
20 Apr 2012, 18:10
David Copeland (103 posts)
There’s two things at play.
1 - /usr/bin/env requires an argument to work, so your shebang line should read:
That tells @env@ to run the command @ruby@ from wherever it is in your environment path.
2 - your app must be in your path, so to run
(Note the @./@). Not sure how far along you are in the book, but if you have setup a project with the executable in the @bin@ directory, then you’d need to do
Essentially, since your @PATH@ doesn’t contain the current directory or your project’s @bin@ directory, you need to explicitly include the path to the executable.
If all that sounds awful, it’s not a big deal when users install apps with RubyGems, since the executable gets installed into a location that is likely in the user’s path.
28 Oct 2012, 11:48
Weihong Guan (1 post)
I just began reading this book. It is quite inspiring. I believe it would be better if adding
before excute it. For bash guys, this is quick basic, while for fleshmen, it is quite an issue.
|You must be logged in to comment|