Rails - the system cannot find the specified path

I installed Rails and Ruby on Windows using railsinstaller. The problem is that when I run the rails command, it gives me: "The system cannot find the path specified."

I am running windows 7 x64 and Ruby 2.20.

I tried uninstalling Rails and installing it again; It does not help. Ruby commands are executed, for example ruby -v , but rails -v= does not work.

+52
windows ruby ruby-on-rails
Feb 22 '16 at 3:31
source share
10 answers

Solution asked on github railsinstaller issues - https://github.com/railsinstaller/railsinstaller-windows/issues/73

+20
Feb 28 '16 at 9:25
source share

Go to C: \ RailsInstaller \ Ruby2.2.0. In some of the .bat files you will 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" %* 

Remove this 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" %* 
+100
Feb 28 '16 at 9:27
source share

This is due to an error in RailsInstaller where two files have ruby.exe location with hard code to work only on the RailsInstaller dev machine. In C:\RailsInstaller\Ruby2.2.0\bin\rails.bat (this is the default installation folder, you can have rails.bat somewhere else, if you chose a different installation folder), you will 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 user emachnic is the developer of RailsInstaller. As a workaround, you can change these folders to those located on your computer. For the default installation folder, you change them 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 need to repeat this change for two similar lines in C:\RailsInstaller\Ruby2.2.0\bin\bundle.bat .

Run rails -v to verify that the rails are now working.

You can follow this issue in your git repository here: https://github.com/railsinstaller/railsinstaller-windows/issues/70

+41
Mar 01 '16 at 18:45
source share

I opened all the .bat files in C: \ RailsInstaller \ Ruby2.2.0 \ bin in Sublime Text and replaced it with Ctrl+Shift+F ,

this is
@"C:\Users\emachnic\GitRepos\railsinstaller-windows\stage\Ruby2.2.0\bin\ruby.exe"
with this
@"%~dp0ruby.exe"
for all files that have a match.

Took just a couple of seconds. It might help someone who came across him after me, and he is discouraged by the idea of ​​doing a search and replacing with several files.

+9
Apr 15 '16 at 21:11
source share

I solved this problem on my windows machine by doing

  • gem package
  • package installation
  • Number 1 and 2 fixed the problem and installed all the gems.
+9
Aug 30 '16 at 21:59
source share

I created a super easy way to make @JayantBhawal's solution (worked fine for me) with Windows Powershell , which you should have all of this since it seems like a problem exclusive to Windows machines. It looks complicated, but in fact everything it does replaces all instances of C:\Users\emachnic\GitRepos\railsinstaller-windows\stage\Ruby2.2.0\bin\ruby.exe with %~dp0ruby.exe in .bat files. Just open Powershell, cd to C:\RailsInstaller\Ruby2.3.0\bin and copy this little 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 press enter, you should find that all instances of this line have been replaced. GL

edit: updated version 2.2.0 β†’ 2.3.0

+3
May 14 '16 at 2:23
source share

I came across this question a couple of days ago. It seems that after running Rails on Windows many times, you play with the cmd command prompt, change the background colors of the commands and text, or open several command prompt windows at the same time, and then try to run the command 'rails server' 'rails new App' or 'bundle install' you get the message "The system cannot find the specified path"

I solved this problem by running the command: 'gem install _____' (fill this line: 'bundle', 'bundler' and 'byebug'), which are the names of the three .bat files (run this command with each .bat name of the ONE AT file TIME). Once you do, check it out! Try creating a new application, installing the package and rails server. It worked for me.

+2
Jun 06 '16 at 9:53 on
source share

I ran into the same problem and ran gem install rails on the command line where it works.

Regards, TS

+1
Apr 25 '17 at 6:33
source share

I found your question by researching the same problem before, and I just fixed it for myself (Windows 8.1), so I decided to answer it. I tried to run Ruby 2.2 on Windows 8.1 using RailsInstaller. Now I can run Ruby and Rails, although an older version. I think this is a problem with 64bit architecture or 32bit version, the latter of which seems to work fine. Here is how I did it:

  • Read this blog post first and see if this solves your problem, although I don’t think it will. I used regedit.exe to search for an instance of AutoRun. I did not have it, so I tried to take the next step.

  • Uninstall the RailsInstaller version of Ruby 2.2 (go to your control panel > programs and features , then uninstall RailsInstaller .

  • Then install version 1.9.3. Go here and CTRL + F "1.9" to find the version of RailsInstaller Ruby 1.9.3.

  • After installation, be sure to run gem update --system to update all your gems. I was not able to run rails new until I updated gem. Now everything is working fine.

So, you will use a slightly older version of Ruby, but everything should work fine. This solution worked for me, and I hope it works for you.

0
Feb 24 '16 at 16:10
source share

I find the fix for the above problem is very simple.

The problem arises because in the installation directory the package you have takes the default path. For example, let's say that you run the following command: install the package Now, to execute this command, the package batch file must be configured correctly. By default, the batch file will have the following structure:

 @ECHO OFF IF NOT "%~f0" == "~f0" GOTO :WinNT @"C:\Users\emachnic\GitRepos\railsinstaller-windows\stage\Ruby2.3.0\bin\ruby.exe" "C:/Users/emachnic/GitRepos/railsinstaller-windows/stage/Ruby2.3.0/bin/bundle" %1 %2 %3 %4 %5 %6 %7 %8 %9 GOTO :EOF :WinNT @"C:\Users\emachnic\GitRepos\railsinstaller-windows\stage\Ruby2.3.0\bin\ruby.exe" "%~dpn0" % 

For me, the rails are installed in the C drive: C: \ RailsInstaller \ Ruby2.3.0 \ bin , so the above batch file should be configured something like this:

 @ECHO OFF IF NOT "%~f0" == "~f0" GOTO :WinNT @"C:/RailsInstaller/Ruby2.3.0/bin/ruby.exe" "C:/RailsInstaller/Ruby2.3.0/bin/bundle" %1 %2 %3 %4 %5 %6 %7 %8 %9 GOTO :EOF :WinNT @"C:/RailsInstaller/Ruby2.3.0/bin/ruby.exe" "%~dpn0" % 

This will solve the above problem.

The above solution should be applied if we are faced with the problem of executing a command.

0
Feb 23 '17 at 20:05
source share



All Articles