• We’re currently investigating an issue related to the forum theme and styling that is impacting page layout and visual formatting. The problem has been identified, and we are actively working on a resolution. There is no impact to user data or functionality, this is strictly a front-end display issue. We’ll post an update once the fix has been deployed. Thanks for your patience while we get this sorted.

How can I execute ruby files from any directory via command prompt?

Er0si0n

Junior Member
I just installed ruby and want to try to start learning a little bit on it. So i installed ruby in to the default directory c:\ruby

I then created a directory to store my ruby apps in c:\rubyapps

Now I want to be able to execute my apps in this directory by just typing ruby whatever.rb in that directory, but I can't. I can only do this if i am in the c:\ruby\bin directory and do ruby c:\rubyapps\whatever.rb.

So my question is how can I make is so i can exec ruby files from any folder not just that bin folder?
 
you have to add the directory containg ruby to the "PATH" environmental variable
If you are in Windows XP, go to control panel->system->advanced->environmental variables, then find the variable "PATH". choose edit and append ;c:\path_to_ruby (don't forget the ";" if the variable already contains information! else you don't need it). If you don't see the "PATH" variable just add it, either user or system section is fine.

You can make it even easier to use by associating the ruby command with .rb files. Just right click a .rb file and choose "Open with...", browse for ruby and check "Always use this program". Now you just have to type the file name to run it.
 
Back
Top