Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Error when trying to invoke the rails command via Cygwin on windows (installed via railsinstaller)

I have followed this tutorial for installing ruby on rails on windows. (the steps are explained in the video in the middle of the page)

If I run the rails command in a classic windows shell (windows + r > cmd > enter), it works fine. However, I would like to be able to invoke it in a cygwin shell. But if I do, for example:

$> rails s # in cygwin

I have the following error:

C:\RailsInstaller\Ruby1.9.3\bin\ruby.exe: No such file or directory -- /cygdrive/c/RailsInstaller/Ruby1.9.3/bin/rails (LoadError)

I've looked into this folder:C:\RailsInstaller\Ruby1.9.3\bin\, and there is indeed no rails.exe, but only a rails and rails.bat file.

rails.bat looks like this:

@ECHO OFF
IF NOT "%~f0" == "~f0" GOTO :WinNT
@"ruby.exe" "C:/Projects/railsinstaller/stage/Ruby1.9.3/bin/rails" %1 %2 %3 %4 %5 %6 %7 %8 %9
GOTO :EOF
:WinNT
@"ruby.exe" "%~dpn0" %*

I only know that cygwin looks for .exe files (for example, if you type cp, is it going to execute the cp.exe executable). I don't know how .bat files works.

So do you know how I can make cygwin able to invoke the rails command ?

like image 391
Benjamin Crouzier Avatar asked Dec 07 '25 21:12

Benjamin Crouzier


2 Answers

As you've stated, the rails on windows is a ".bat" file. Just use the ".bat" extension in every command. It worked for me.

Try and see: "rails.bat -v" (in Cygwin)

like image 192
Fernando Vieira Avatar answered Dec 10 '25 11:12

Fernando Vieira


I faced the same issue in cygwin but the "rails" command was working fine in windows cmd prompt. As a turn around Invoke the following command in cygwin,
alias rails='path_to_ruby_installed_directory/bin/rails.bat'

In your case,
alias rails ='C:/Projects/railsinstaller/stage/Ruby1.9.3/bin/rails.bat'

To make the alias permanent, Edit the .bashrc file in CYGWIN home directory and add the above alias in it.

like image 41
balajivijayan Avatar answered Dec 10 '25 11:12

balajivijayan



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!