I have installed Rails and Ruby on Windows with railsinstaller. The problem is, when I run the rails command, it gives me: \"The system cannot find the path specified.\"
Go into C:\RailsInstaller\Ruby2.2.0. In some of the .bat files, you'll find the following:
@ECHO OFF
IF NOT "%~f0" == "~f0" GOTO :WinNT
@"C:\Users\emachnic\GitRepos\railsinstaller-windows\stage\Ruby2.2.0\bin\ruby.exe" "C:/Users/emachnic/GitRepos/railsinstaller-windows/stage/Ruby2.2.0/bin/tilt" %1 %2 %3 %4 %5 %6 %7 %8 %9
GOTO :EOF
:WinNT
@"C:\Users\emachnic\GitRepos\railsinstaller-windows\stage\Ruby2.2.0\bin\ruby.exe" "%~dpn0" %*
Delete that and paste in the text below:
@ECHO OFF
IF NOT "%~f0" == "~f0" GOTO :WinNT
ECHO.This version of Ruby has not been built with support for Windows 95/98/Me.
GOTO :EOF
:WinNT
@"%~dp0ruby.exe" "%~dpn0" %*
I found your question while researching the same problem earlier, and I just fixed it for myself (Windows 8.1) so I thought I would answer it. I was trying to run Ruby 2.2 on Windows 8.1 using RailsInstaller. I am now able to run Ruby and Rails, albeit an older version. I think this is a problem with 64-bit architecture versus 32-bit, the latter of which seems to run fine. Here's how I did it:
First, read this blog post and see if this solves your problem, though I don't think it will. I used regedit.exe
to find the AutoRun instance in question. I didn't have one, so I tried the next step.
Uninstall the Ruby 2.2 version of RailsInstaller (go into your control panel
> programs and features
then uninstall RailsInstaller
.
Then, install the 1.9.3 version. Go here and CTRL+F "1.9" to find the Ruby 1.9.3 version of RailsInstaller.
Once installed, make sure to run a gem update --system
to update all of your gems. I had trouble running rails new
until I did the gem update. Now everything works fine.
So, you'll be using a slightly older version of Ruby but everything should be working okay. This solution worked for me and I hope it works for you.
I encountered the same issue and running gem install rails
in the command prompt it works.
Regards, T.S.
I've created a super easy way to do @JayantBhawal's solution (worked perfectly fine for me) with Windows Powershell, which you should all have since this seems like a problem exclusive to Windows machines. It looks complicated but really all it's doing is replacing all the instances of C:\Users\emachnic\GitRepos\railsinstaller-windows\stage\Ruby2.2.0\bin\ruby.exe
with %~dp0ruby.exe
in the .bat files. Just open up Powershell, cd to C:\RailsInstaller\Ruby2.3.0\bin
, and copy this small script:
Get-ChildItem . -Filter *.bat | Foreach-Object {
(Get-Content $_.name ) | ForEach-Object {
$_ -replace "C:\\Users\\emachnic\\GitRepos\\railsinstaller-windows\\stage\\Ruby2.2.0\\bin\\ruby.exe", "%~dp0ruby.exe"
} | Set-Content $_.name}
After you hit enter, you should find that all the instances of that string have been replaced. GL
edit: updated version 2.2.0 -> 2.3.0
This is due to a bug in RailsInstaller, where two files have the location of ruby.exe
hard-coded to work only on the RailsInstaller dev's machine. In C:\RailsInstaller\Ruby2.2.0\bin\rails.bat
(this is the default install folder, you might have rails.bat
somewhere else if you picked a different install folder) you'll find these two lines:
@"C:\Users\emachnic\GitRepos\railsinstaller-windows\stage\Ruby2.2.0\bin\ruby.exe" "C:/Users/emachnic/GitRepos/railsinstaller-windows/stage/Ruby2.2.0/bin/rails" %1 %2 %3 %4 %5 %6 %7 %8 %9
@"C:\Users\emachnic\GitRepos\railsinstaller-windows\stage\Ruby2.2.0\bin\ruby.exe" "%~dpn0" %*
The emachnic user is the RailsInstaller developer. As a workaround, you can change these folders to the ones on your computer. For the default install folder, you'd change these to:
@"C:\RailsInstaller\Ruby2.2.0\bin\ruby.exe" "C:\RailsInstaller\Ruby2.2.0\bin\rails" %1 %2 %3 %4 %5 %6 %7 %8 %9
@"C:\RailsInstaller\Ruby2.2.0\bin\ruby.exe" "%~dpn0" %*
You will have to repeat this change for two similar lines in C:\RailsInstaller\Ruby2.2.0\bin\bundle.bat
as well.
Run rails -v
to verify that rails is now working.
You can follow this issue on their git repo here: https://github.com/railsinstaller/railsinstaller-windows/issues/70
I solved this problem on my windows machine by doing