How to run Ruby and GIT commands in one place on Windows

28,055

Solution 1

I run git commands from the CMD session all the time.

Make sure your PATH environment variable includes the 'cmd' directory from a msysgit distro:

Path=C:\Path\To\Git\1.7.1\cmd

If not, add it in your session:

set PATH=%PATH%;C:\Path\To\Git\1.7.1\cmd

and you are done. Git and Ruby commands in your CMD shell.

The reverse (Ruby commands) is possible in a Git bash, by adding to the PATH a value like /c/path/to/Ruby/186-27/bin

http://img842.i_mageshack.us/img842/8749/gitbashruby.png

Solution 2

To elaborate on VonC's answer of making Ruby available in Git-Bash.

All you have to do is add the path to your Ruby bin folder in your windows environment variables. It doesn't have to be in the format /c/path/to/ruby, it can be C:\Ruby193\bin.

Step by step for Windows 7:

  1. Start
  2. Search programs and files (default textbox after hitting the Start icon), Search for 'environment'
  3. Select 'edit the system environment variables'
  4. Click 'Environment Variables' (bottom right of the form)
  5. Add to the 'System Variables' 'PATH' the following ';C:\Ruby193\bin' (without the single quotes)
  6. Restart your shell

Make sure to close your git-bash shell and restart it to pick up the new environment variable.

Solution 3

  • Go to My Computer -> Properties -> Advanced system settings -> Environment Variables

  • Add a New System variable. Variable name = RUBY_BIN. Variable value = C:\Ruby193\bin (path may vary).

  • Add a New System variable. Variable name = MSYSGIT_BIN. Variable value = C:\msysgit\bin (path may vary).

  • Append ;%RUBY_BIN%;%MSYSGIT_BIN% to Path variable, under System variables.

  • Restart shell.

This will allow you to run ruby, git or sh (Git Bash) commands from Command Prompt, as well as Ruby from Git Bash.

Share:
28,055
Joseph U.
Author by

Joseph U.

Updated on July 09, 2022

Comments

  • Joseph U.
    Joseph U. almost 2 years

    I have Ruby and GIT installed on my windows box. To run GIT commands I am utilizing the GIT Bash. To run Ruby commands I am using the command line.

    I have not been successful running GIT commands from the CMD line nor can I seem to run Ruby commands from inside the GIT Bash. I would love to be able to run commands for both GIT and Ruby from the GIT Bash (ideal) or at the least from the CMD line.

    What is the best way to go about this?