Reputation: 41965
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 ?
Upvotes: 3
Views: 2139
Reputation: 889
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.
Upvotes: 2
Reputation: 2702
Add this to your .bashrc or .zshrc to create alias for all appropriate .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 https://stackoverflow.com/a/19424481/1248256
Upvotes: 0
Reputation: 3333
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)
Upvotes: 2
Reputation: 890
I've been suffer from this problem for such a long time, and I've just found an 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 is gonna be something like: /cygdrive/d/RailsInstaller/Ruby1.9.3/bin/ruby.exe
and then rails can be invoked within cygwin.
Upvotes: 0
Reputation: 637
It is not recommended to use Cygwin since everything is set up for use with Command Prompt. You may be able to get git-bash working but the Command Prompt included with RI is the supported method of using RailsInstaller. If you want to use Cygwin, I'd suggest not using RailsInstaller.
Upvotes: 1