ChaosFreak
ChaosFreak

Reputation: 101

"'rails' is not recognized as an internal or external command, operable program or batch file" when trying to create new app

I've followed the instructions in https://devcenter.heroku.com/articles/rails3 which is missing a lot of crucial information for Windows installs, but managed to get past most of my problems with Google searches.

Here's what I've done:

  1. Installed Heroku Toolbelt
  2. Tried "heroku login" but ssh-keygen wasn't found so added C:\Program Files (x86)\Git\bin; to %PATH% -- was then able to generate key and log in
  3. Tried "rails new myapp" but got the error in the title of this thread (rails command not found)
  4. Tried "gem install rails" but the "gem" command also not found. Added C:\Program Files (x86)\Heroku\bin;C:\Program Files (x86)\Heroku\ruby-1.9.2\bin; to %PATH%.
  5. Tried "gem install rails" again. Command runs but hits error saying devkit not installed.
  6. Installed devkit and added C:\Program Files (x86)\Heroku\ruby-1.9.2\devkit;C:\Program Files (x86)\Heroku\ruby-1.9.2\devkit\bin; to %PATH%
  7. Finally "gem install rails" completes successfully
  8. Tried "rails new myapp" again but still get the error 'rails' is not recognized as an internal or external command, operable program or batch file.
  9. Searched my entire C: drive for "rails.*" but no executable found anywhere. So, "gem install rails" completed with no errors but there's no "rails" executable anywhere on my system.

Any help?

PS - Please no "you typed xxx wrong" answers. I may have mistyped something in this question but I always triple-check that I'm typing commands with proper case and spelling. Also, I have been exiting and opening new command prompts to reload PATH.

Upvotes: 1

Views: 15558

Answers (4)

Kailas Kakade
Kailas Kakade

Reputation: 53

This message means that Rails cannot be found. This might be due to the fact that you haven’t installed Rails or it may be due to the fact that the path to Rails cannot be found. This may also occur when you install Rails using a ‘special’ installation of Rails such as the InstantRails installer. We do not support custom Rails installers. We recommend that you do a ‘normal’ Rails installation. To do this from within Ruby In Steel, ensure that you are connected to the Internet, then select Gems from the Ruby menu and enter:

rails –include-dependencies

If you prefer to run the gem from the system prompt, you should enter:

gem install rails –include-dependencies

Alternatively, you can download and install rails from the Ruby On Rails web site:

http://www.rubyonrails.org/

To ensure that Rails is installed, go to the system prompt and enter:

rails

You should see a screen of help information relating to Rails. If you still see the message, “’rails’ is not recognized as an internal or external command, operable program or batch file.” then Rails is not installed. You must have a workable installation of Rails in order to develop Rails applications with Ruby In Steel.

Upvotes: 0

Faruk
Faruk

Reputation: 5841

I think you just need to close the windows explorer and all cmd window. And then open windows explorer again, and start command prompt again in the ../ruby/rails

Oh, by the way you can use shift + right mouse click, to get menu "Open command window here" in the explorer.

Upvotes: 1

Romans 8.38-39
Romans 8.38-39

Reputation: 456

I think you need to get rid all of your installed Ruby especially the PATH and download Ruby on Rails for Windows (http://rubyforge.org/frs/download.php/76862/railsinstaller-2.2.1.exe) Once you installed this, the installer will do the setting and everything including setting up the environment variables. After you installed, I think you need to restart your laptop. You can open "command prompt with Ruby on Rails" directly from the one you installed... then try rails command (such as rails c, rails new, etc) I've tried this on my windows 7 64bit laptop and it works perfectly fine :D

Good luck!

Upvotes: 2

cfeduke
cfeduke

Reputation: 23236

See if you have any luck with Rails Installer.

An alternative, and I know this sounds like a very bad idea to you right now, is to install VirtualBox (free) with Ubuntu as a virtual machine and develop on Linux for a while using an editor like SublimeText 2 or vim. You'll definitely have an easier time following along in tutorials and not get frustrated with the language due to the operating system.

Upvotes: 1

Related Questions