![]() | 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… MY_RUBY_HOME=/home/tallercreativo/.rvm/rubies/ruby-1.9.2-p290 PATH=/home/tallercreativo/.rvm/gems/ruby-1.9.2-p290/bin:/home/tallercreativo/.rvm/gems/ruby-1.9.2-p290@global/bin:/home/tallercreativo/.rvm/rubies/ruby-1.9.2-p290/bin:/home/tallercreativo/.rvm/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games GEM_PATH=/home/tallercreativo/.rvm/gems/ruby-1.9.2-p290:/home/tallercreativo/.rvm/gems/ruby-1.9.2-p290@global RUBY_VERSION=ruby-1.9.2-p290 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. What’s wrong? |
|
20 Apr 2012, 18:10
David Copeland (85 posts) |
There’s two things at play. 1 – /usr/bin/env requires an argument to work, so your shebang line should read:
That tells 2 – your app must be in your path, so to run `todo.rb` from the current directory, you’d need to do
(Note the
Essentially, since your 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 chmod +x todo.rb 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 |

