When I run a ruby program from the command line, I have to add "ruby" at the beginning of the command (ex. 'ruby hangman.rb'). My question is, how do I make a command line program without having to use 'ruby' in front to run the program. I know this has to be possible because RoR is written in ruby and you don't have to run "ruby rails [command]", you just run "rails". Any Ideas?
            Asked
            
        
        
            Active
            
        
            Viewed 47 times
        
    0
            
            
        - 
                    1If you are on windows, you may want to compile ruby. https://stackoverflow.com/questions/9998819/compile-ruby-script-into-exe – James T Kirk Jan 21 '18 at 21:29
 - 
                    1This is documented heavily. You'll want to look up discussions on `bin` — RubyGems has a nice guide on making an executable, http://guides.rubygems.org/make-your-own-gem/#adding-an-executable – Josh Brody Jan 21 '18 at 21:30
 - 
                    Rails is a gem. Gems are generally run from somewhere in your PATH. See also `gem env`. – Todd A. Jacobs Jan 21 '18 at 22:31
 - 
                    It would appear I have some research to do. Thanks! – Cody Mudrack Jan 21 '18 at 22:55
 
1 Answers
1
            
            
        Best option would be to bundle it as a Gem - this allows to define an executable.
Another a bit "hacky" option would be to create a hangman.bat file that would just call ruby hangman.rb
Note that both cases would still require ruby to be installed on any target computer.
        Martin
        
- 7,634
 - 1
 - 20
 - 23