简体   繁体   English

试图在Windows 7上的Rails(版本4.0.0)上重新安装Ruby(版本2.0.0)

[英]Attempting to re-install Ruby (version 2.0.0) on Rails (version 4.0.0) on Windows 7

I had Ruby-on-Rails installed, but it was Ruby version 1.9.3. 我安装了Ruby-on-Rails,但它是Ruby版本1.9.3。 It was installed via the Railsinstaller. 它是通过Railsinstaller安装的。 Since I am just starting in RoR, I wanted to start with the most updated versions to go through the Ruby on Rails Tutorial. 由于我刚刚开始使用RoR,我想从最新版本开始,通过Ruby on Rails教程。 Rails was easy enough to update, but not Ruby itself. Rails很容易更新,但不是Ruby本身。

I uninstalled the existing RailsInstaller, deleted the c:\\Railsinstaller directory and downloaded the latest version of RailsInstaller, version 3.0.0-alpha.1. 我卸载了现有的RailsInstaller,删除了c:\\ Railsinstaller目录并下载了最新版本的RailsInstaller,版本3.0.0-alpha.1。

Upon install it launches a command prompt window that should list the install infor for git, ruby and rails. 安装后,它会启动一个命令提示符窗口,该窗口应列出git,ruby和rails的安装信息。 Instead I got this error: 相反,我得到了这个错误:

The system cannot find the path specified.

 Rails Environment Configuration.  
C:/RailsInstaller/scripts/config_check.rb:28:in ``': No such file or directory -  
 rails -v (Errno::ENOENT)  
        from C:/RailsInstaller/scripts/config_check.rb:28:in `run'  
        from C:/RailsInstaller/scripts/config_check.rb:83:in `<main>'  
C:\Sites>

Line 28 is part of this block: 第28行是该块的一部分:

def run(command)
  $stderr.puts "Running #{command}" if Config[:debug]
  %x{#{command}}.chomp
end

and line 83 is this inside of a 'puts' block: 第83行是'puts'块的内部:

  version:    #{run "rails -v"}

manually running "rails -v" 手动运行“rails -v”

C:\Sites>rails -v
'rails' is not recognized as an internal or external command,
operable program or batch file.

attempting "ruby rails.rb" ruby: No such file or directory -- rails.rb (LoadError) 尝试“ruby rails.rb”ruby:没有这样的文件或目录 - rails.rb(LoadError)

attempting to manually install the rails gem 试图手动安装rails gem

c:\Sites>gem install rails --version 4.0.0  

Fetching: i18n-0.6.4.gem (100%)  
Successfully installed i18n-0.6.4  
Fetching: atomic-1.1.10.gem (100%)  
Temporarily enhancing PATH to include DevKit...  
Building native extensions.  This could take a while...  
The system cannot find the path specified.  
ERROR:  Error installing rails:  
        ERROR: Failed to build gem native extension.  

    C:/RailsInstaller/Ruby2.0.0/bin/ruby.exe extconf.rb  
creating Makefile  


Gem files will remain installed in C:/RailsInstaller/Ruby2.0.0/lib/ruby/gems/2.0  
.0/gems/atomic-1.1.10 for inspection.  
Results logged to C:/RailsInstaller/Ruby2.0.0/lib/ruby/gems/2.0.0/gems/atomic-1.  
1.10/ext/gem_make.out  

The gem_make.out only contains: gem_make.out仅包含:

C:/RailsInstaller/Ruby2.0.0/bin/ruby.exe extconf.rb  
creating Makefile

I attempted to install Railsinstaller 3.0.0 on a windows xp machine to test, and got the same error after the install, running "rails -v" failed in the same way, but running "gem install rails --version 4.0.0" worked. 我试图在Windows XP机器上安装Railsinstaller 3.0.0进行测试,并在安装后得到相同的错误,运行“rails -v”以同样的方式失败,但运行“gem install rails --version 4.0.0”工作。

Did something persist from the previous install that is preventing the new install from functioning properly? 以前的安装中是否存在阻止新安装正常运行的问题?

I think something is still trying to go to the Ruby1.9.3 forlder and/or subfolders and failing, but can't find anything referencing that directory. 我认为有些东西仍然试图转到Ruby1.9.3 forlder和/或子文件夹并失败,但找不到任何引用该目录的东西。

After a bunch of additional research and out side help, found this: 经过一系列额外的研究和外面的帮助后,发现了这个:

You've installed both RubyInstaller and DevKit following the instructions but during gem installation, you receive a message like this: 您已按照说明安装了RubyInstaller和DevKit,但在gem安装过程中,您会收到如下消息:

C:\devkit>gem install rdiscount --platform=ruby
Temporarily enhancing PATH to include DevKit...
Building native extensions.  This could take a while...
ERROR:  Error installing rdiscount:
       ERROR: Failed to build gem native extension.

C:/ruby/bin/ruby.exe extconf.rb
C:/ruby/bin/ruby.exe: No such file or directory -- extconf.rb
(LoadError)

Or sometimes just this: 或者有时只是这样:

ERROR:  Error installing rdiscount:
       ERROR: Failed to build gem native extension.

       C:/Ruby187/bin/ruby.exe extconf.rb

This has been reported to our group here and here. 这已经在我们这里和这里报告过了。

After a long back and forth investigation, we found two possible causes for this issue: COMSPEC environment variable (scenario A) and AutoRun registry setting (scenario B), both described below: 经过长时间的来回调查,我们发现了两个可能的原因:COMSPEC环境变量(场景A)和AutoRun注册表设置(场景B),两者都描述如下:

Scenario A 情景A.

Using a command prompt, invoke the following command: 使用命令提示符,调用以下命令:

SET COMSPEC

If in the output you see something different than cmd.exe as value for that variable, then please adjust it to use cmd.exe 如果在输出中您看到与cmd.exe不同的值作为该变量的值,则请将其调整为使用cmd.exe

Some tools might change your command processor command, which interferes with Ruby invoking child processes. 某些工具可能会更改命令处理器命令,这会干扰Ruby调用子进程。

Change that and try to install the gem again. 改变它并尝试再次安装gem。

Scenario B 情景B

If the problem persist, invoke the following commands in the same command prompt: 如果问题仍然存在,请在同一命令提示符中调用以下命令:

REG QUERY "HKCU\Software\Microsoft\Command Processor"
REG QUERY "HKLM\Software\Microsoft\Command Processor" /s

Execute each line individually. 单独执行每一行。 Once you run it, will see something like this: 运行后,会看到如下内容:

HKEY_CURRENT_USER\Software\Microsoft\Command Processor
    CompletionChar    REG_DWORD    0x9
    DefaultColor    REG_DWORD    0x0
    EnableExtensions    REG_DWORD    0x1
    PathCompletionChar    REG_DWORD    0x9

The columns of information are Key, Type and Value. 信息列是密钥,类型和值。 If you see a key named AutoRun, there is a chance this is the culprit of the error you're receiving. 如果您看到名为AutoRun的密钥,则可能是您收到的错误的罪魁祸首。

AutoRun interferes with Ruby messing with child process executing and by result, affecting gem installation. AutoRun干扰Ruby搞乱子进程执行和结果,影响gem安装。 Please remove it with the following command: 请使用以下命令将其删除:

REG DELETE "HKCU\Software\Microsoft\Command Processor" /v AutoRun

Once you're done, try opening a new command prompt and executing gem installation again. 完成后,尝试打开新的命令提示符并再次执行gem安装。

Scenario B ended up being the culprit and things began working properly once that was completed. 情景B最终成为罪魁祸首,一旦完成,事情就开始正常运作。

I apologize that this doesn't actually answer your question at hand, but I think it's still useful advice to you: 我道歉,这实际上并没有回答你手头的问题,但我认为这对你来说仍然是有用的建议:

Consider downloading Virtualbox and installing some Linux (Fedora, Ubuntu) on it and doing your Rails development on that Linux virtual machine. 考虑下载Virtualbox并在其上安装一些Linux(Fedora,Ubuntu)并在该Linux虚拟机上进行Rails开发。 It won't mess with your Windows system at all, but it will be much easier to develop Rails with. 它根本不会弄乱你的Windows系统,但用它开发Rails会容易得多。

Almost nobody develops Rails on Windows, everyone uses Mac or Linux it seems. 几乎没有人在Windows上开发Rails,似乎每个人都使用Mac或Linux。 And I always read people having problems setting it up on Windows. 而且我总是读到在Windows上设置它时遇到问题的人。 It just doesn't seem worth the effort to me when you have free tools out there to develop on Linux. 当你在Linux上开发免费工具时,对我来说似乎不值得努力。

Again, sorry this isn't actually the proper answer to the question. 再说一遍,对不起,这实际上并不是问题的正确答案。 Even once you find the answer to your problem, I'd still recommend you consider this advice. 即使您找到问题的答案,我仍然建议您考虑这个建议。 You're likely to have more problems with Rails on Windows. 在Windows上,你可能会遇到更多Rails问题。

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

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