简体   繁体   English

rails --version命令在Windows上不起作用

[英]rails --version command not working on Windows

I installed Rails from http://railsinstaller.org/en on my Windows 7 desktop and the installation went fine. 我从Windows 7桌面上的http://railsinstaller.org/en安装了Rails,安装正常。 However, after installation when I do: 但是,安装后当我这样做时:

C:\Sites>rails --version
The system cannot find the path specified.

C:\Sites>ruby -v
ruby 2.2.4p230 (2015-12-16 revision 53155) [i386-mingw32]

C:\Sites>gem -v
2.4.5.1

After much digging around I found errors in a few of the *.bat (nokogiri, scss,...) files located in C:\\path\\to\\RailsInstaller\\Ruby2.2.0\\bin . 经过大量挖掘之后,我发现位于C:\\path\\to\\RailsInstaller\\Ruby2.2.0\\bin中的*.bat (nokogiri,scss ...)文件中的一些错误。

This was the content of rails.bat : 这是rails.bat的内容:

@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/rails" %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" %*`

After removing the hardcoded paths C:\\Users\\emachnic\\GitRepos\\railsinstaller-windows\\stage\\Ruby2.2.0\\bin\\ , the rails command reports the correct version: 删除硬编码的路径C:\\Users\\emachnic\\GitRepos\\railsinstaller-windows\\stage\\Ruby2.2.0\\bin\\rails命令将报告正确的版本:

C:\path\to\RailsInstaller3.2\Ruby2.2.0\bin>rails -v
Rails 4.2.5.1

Found the problem. 找到了问题。 It looks like the distributable ( railsinstaller-3.2.0.exe which uses Ruby 2.2 ) provided on rails installer site ( http://railsinstaller.org/en ) is having some problem. 看起来Rails安装程序站点( http://railsinstaller.org/en )上提供的可分发文件( railsinstaller-3.2.0.exe which uses Ruby 2.2 )出现了问题。 When I picked the older version ( railsinstaller-3.1.1.exe which uses Ruby 2.1 ) it was able to pick the rails version without any problem. 当我选择较旧的版本( railsinstaller-3.1.1.exe which uses Ruby 2.1 )时,它能够毫无问题地选择rails版本。

C:\>rails --version
Rails 4.2.5.1

C:\>ruby --version
ruby 2.1.8p440 (2015-12-16 revision 53160) [i386-mingw32]

Please note that the ruby version is downgraded from 2.2 to 2.1 here. 请注意,此处将ruby版本从2.2降级到2.1。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM