Ruby in Windows CLI, How to do?
I see in a lot of the tutorials and how to pages, they use the following, or something similar
ruby C:\test.rb
Which would parse test.rb to the interpreter and ... execut开发者_如何学Pythone the script. But how is this done on Windows? Ruby isn't a recognized internal command (as per the shell output)?
I know how to do all these things on Linux, and its as simple as... alas Windows is completely confusing at times :)
Your best bet is going to be to add the path to the Ruby executable to your Environment Variables:
Right click on 'Computer' in Windows.
Click 'Properties...'
Select the 'Advanced' tab.
Click 'Environment Variables'
Find 'Path' in the list and click edit
Add
C:\Ruby\bin;
(or wherever you installed Ruby to) to the end of the string
In Windows, you could add the directory which contains ruby.exe
to the System-Variable Path
, then the above should work. See here for a small tutorial (btw. the directories are separated by ;
(semicolon), not by :
as in UNIX).
Also possible
cd \Path\To\Ruby\Interpreter
ruby.exe C:\test.rb
since .
(the current working directory) is always part of Path
.
精彩评论