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

I followed this tutorial to install rubies on rails on windows. (the steps are described in the video in the middle of the page)

If I run rails command in Windows (classical shell windows + r

> cmd

> enter

), it works fine. However, I would like to be able to call it in the cygwin shell. But if I do this, 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 / Ruby 1.9.3 / bin / rails (LoadError)

I looked in this folder: C:\RailsInstaller\Ruby1.9.3\bin\

and there is actually no rails.exe but only the 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" %*

      

All I know is that cygwin is looking for .exe files (for example, if you type cp

it will execute the executable cp.exe

). I don't know how .bat files work.

Do you know how I can get cygwin to call the rails command?

+3


source to share


5 answers


As you said, rails on windows is a ".bat" file. Just use the ".bat" extension in every command. This worked for me.



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

+2


source


I faced the same problem in cygwin, but the "rails" command worked fine on the windows cmd prompt. How to turn Call 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 the CYGWIN home directory and add the above alias to it.

+2


source


Cygwin is not recommended as everything is configured for use with the command line. You can get git - bash, but the Command Line included with RI is a supported method of using RailsInstaller. If you want to use Cygwin, I would suggest not using RailsInstaller.

+1


source


I have suffered from this issue for so long and I just found a workaround. In cygwin terminal:

ln -s path-of-you-rails-installer / RailsInstaller / Ruby1.9.3 / bin / ruby.exe / bin / ruby ​​ln -s path-of-you-rails-installer / RailsInstaller / Ruby1.9.3 / bin / rails .bat / bin / rails

ps: the full path would be something like: /cygdrive/d/RailsInstaller/Ruby1.9.3/bin/ruby.exe

and then rails can be called in cygwin.

0


source


Add this to your .bashrc or .zshrc to create an alias for all relevant .bat

:

# cygwin
if [[ -n "$(which ruby 2>/dev/null)" ]]; then
  RUBY_BIN=$(cygpath -u $(ruby -e 'puts RbConfig::CONFIG["bindir"]') | tr -d '\r')
  for f in $(find ${RUBY_BIN} -regex ".*bat$"| xargs -n1 basename); do
    alias ${f%.bat}=${f}
  done
fi

      

Thanks fooobar.com/questions/365459 / ...

0


source







All Articles