How to make a Ruby file executable as executable?

I want the Ruby Script file to run as an executable from any Windows XP directory. I created a test.rb file (Ruby Script) and I want to run it from any Windows directory, for example, as "test", "C: \ test" or "C: \ Directory \ test" launches my test.rb file.

#!/usr/bin/envy ruby p "Hi this is my test file" 

I added the shebang code to my ruby ​​file, but when I need to run Ruby Script, I need to find the Script file and execute it explicitly as "ruby test.rb".

I also executed the executable by running the command: $ chmod +x hello-world.rb , but it still does not work.

Thanks in advance.

+4
source share
1 answer

I assume that you are using Linux or OS X and are creating a file on a disk accessible from Windows? Windows does not use shebangs and does not use Unix file modes. You will need to associate the .rb files with the .rb executable; details of this operation can be found on this question ; once you do this, you can run C:\whatever\test.rb or C:\whatever\test to execute the script.

+7
source

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


All Articles