开发者

Ruby in Windows CLI, How to do?

开发者 https://www.devze.com 2022-12-25 12:28 出处:网络
I see in a lot of the tutorials and how to pages, they use the following, or something similar ruby C:\\test.rb

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:

  1. Right click on 'Computer' in Windows.

  2. Click 'Properties...'

  3. Select the 'Advanced' tab.

  4. Click 'Environment Variables'

  5. Find 'Path' in the list and click edit

  6. 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.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号