ruby is not recognized as an internal or external command, operable or batch file error

We are lucky because installing ruby on Windows is pretty easy.

However, people often get the following error and are wondering what to do:

ruby is not recognized as an internal or external command, operable or batch file

If you try to install a gem, gem install [something] won’t be recognized as a command either.

gem is not recognized as an internal or external command, operable or batch file

The reason:

Usually, that happens if you haven’t checked the “Add Ruby executables to your PATH” box during the Ruby installation process. In that case your environment won’t know where your Ruby installation is situated. Here is how to fix that.

Solution 1 Reinstalling Ruby

I would suggest reinstalling. Even though that might not be the best practice, it is fairly easier then the other solution. Just go to your Control Panel and uninstall Ruby. Then run the installation again and make sure you’ve checked the “Add Ruby… PATH” box this time. Then you can continue installing SASS, Compass or whatever you want.


Solution 2 Fix the problem manually

If you want to fix the problem manually, you will need to add the Ruby bin folder to your PATH user variable and add a new system variable to make the gem command work. To do that:

Start menu -> Right click on Computer -> Properties -> Advanced system settings (in the left panel) -> Advanced tab -> Environment Variables button

Step 1 In the User variables section, double click on Path (or select Path and press Edit).

If there is anything else there put a semicolon after it ; and add the path to your Ruby bin folder -> for example C:\Ruby193\bin or C:\Ruby200\bin  Then press OK

ps. the 3 digits are the version of your Ruby installation. Just go to your C: drive and check the name of the Ruby folder.


Step 2 In the System variables section, press New. For variable name enter RYBUOPT and for variable value rubygems Press OK on the small window and on the other two that remained opened.


Step 3 To check if everything is okay now, go back to your Command Prompt window and type in

ruby – v

If you get a message with your ruby version, you managed to solve the problem. Great!


Guest blogger: Stanimira

  • Pingback: How to install SASS with Compass – Windows 7 step by step guide - Wordpress tutorials and tips()

  • Vishnu

    Very Helpful .. Thanks 🙂

  • Majid

    Great article, thanks a billion 😀

  • Luis

    Great article, it helped me a lot! Thanks

  • Tammy

    Thank you this was my problem as well, very helpful.

  • samuel

    Thanks its help me

  • Purush

    Thank you!

  • thanks 😀

  • blk stn


  • Farrukh Mehmood

    thanks your tips solve my issue 🙂

  • Monique Heinz

    Hi I’m trying to make up my mind…is RYBUOPT actually the correct variable or should it maybe be RUBYOPT and there is a typo?

  • Nate Gasser

    Thanks for this — worked like a champ. In Step 3 you might add that you need to open a new windows command prompt after setting these variables in order to take effect.

  • Rachel Stratemeier

    What FINALLY worked for me was moving C:/Ruby22/bin (or whatever your ruby.exe path is) to the BEGINNING of the path variable. for some reason, my path had grown so long that it was like the system just stopped reading it at a certain point. once ruby was at the front, everything worked like it was supposed to.

    Also, not sure if this is related, but i had to add .RB and .RBW to my PATHEXT variable.

  • You’re awesome

  • Sanket


  • सोनिका ठाकुर

    Thank you so much.. it’s work

  • Paula

    doesn’t work 🙁 automatically or manually

  • radek

    Just simple reinstall Ruby and check “Add Ruby…Path”
    Thank You 🙂

  • Nicolas Garcia