【问题标题】:Attempting to re-install Ruby (version 2.0.0) on Rails (version 4.0.0) on Windows 7尝试在 Windows 7 上的 Rails(4.0.0 版)上重新安装 Ruby(2.0.0 版)
【发布时间】:2013-07-20 01:59:39
【问题描述】:

我安装了 Ruby-on-Rails,但它是 Ruby 版本 1.9.3。它是通过 Railsinstaller 安装的。因为我刚开始使用 RoR,所以我想从最新版本开始学习 Ruby on Rails 教程。 Rails 很容易更新,但不是 Ruby 本身。

我卸载了现有的 RailsInstaller,删除了 c:\Railsinstaller 目录并下载了最新版本的 RailsInstaller,版本 3.0.0-alpha.1。

安装时它会启动一个命令提示符窗口,该窗口应列出 git、ruby 和 rails 的安装信息。相反,我得到了这个错误:

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>

第 28 行是此块的一部分:

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

第 83 行是在“puts”块内:

  version:    #{run "rails -v"}

手动运行“rails -v”

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

尝试“ruby rails.rb” ruby: 没有这样的文件或目录 -- rails.rb (LoadError)

尝试手动安装 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  

gem_make.out 只包含:

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

我尝试在 windows xp 机器上安装 Railsinstaller 3.0.0 进行测试,安装后出现同样的错误,运行“rails -v”以同样的方式失败,但运行“gem install rails --version 4.0 .0" 有效。

之前的安装是否存在导致新安装无法正常运行的问题?

我认为某些东西仍在尝试转到 Ruby1.9.3 forlder 和/或子文件夹并失败,但找不到任何引用该目录的内容。

【问题讨论】:

    标签: ruby-on-rails gem railsinstaller


    【解决方案1】:

    经过大量额外研究和外部帮助后,发现:

    您已按照说明安装了 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)
    

    或者有时只是这样:

    ERROR:  Error installing rdiscount:
           ERROR: Failed to build gem native extension.
    
           C:/Ruby187/bin/ruby.exe extconf.rb
    

    我们已在此处和此处向我们的小组报告此事。

    经过漫长的反复调查,我们发现了导致此问题的两个可能原因:COMSPEC 环境变量(场景 A)和 AutoRun 注册表设置(场景 B),如下所述:

    场景 A

    使用命令提示符,调用以下命令:

    SET COMSPEC
    

    如果您在输出中看到与 cmd.exe 不同的值作为该变量的值,请调整它以使用 cmd.exe

    某些工具可能会更改您的命令处理器命令,这会干扰 Ruby 调用子进程。

    更改它并尝试再次安装 gem。

    场景 B

    如果问题仍然存在,请在同一命令提示符下调用以下命令:

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

    单独执行每一行。运行后,会看到如下内容:

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

    信息的列是键、类型和值。如果您看到一个名为 AutoRun 的键,这很可能是您收到错误的罪魁祸首。

    AutoRun 会干扰 Ruby 干扰子进程的执行,从而影响 gem 安装。请使用以下命令将其删除:

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

    完成后,尝试打开新的命令提示符并再次执行 gem 安装。

    场景 B 最终成为罪魁祸首,一旦完成,事情就开始正常工作。

    【讨论】:

      【解决方案2】:

      很抱歉,这实际上并没有回答您手头的问题,但我认为这对您仍然有用:

      考虑下载 Virtualbox 并在其上安装一些 Linux(Fedora、Ubuntu)并在该 Linux 虚拟机上进行 Rails 开发。它完全不会影响您的 Windows 系统,但使用它开发 Rails 会容易得多。

      几乎没有人在 Windows 上开发 Rails,似乎每个人都使用 Mac 或 Linux。而且我总是读到有人在 Windows 上设置它时遇到问题。当你有免费的工具在 Linux 上开发时,对我来说似乎不值得付出努力。

      再次抱歉,这实际上不是问题的正确答案。即使你找到了问题的答案,我仍然建议你考虑这个建议。在 Windows 上使用 Rails 时可能会遇到更多问题。

      【讨论】:

      • 我同意这不是一个实际的答案,而是非常有用的建议。我在 Linux 上使用 ruby​​ 做了很多工作,并试图在我的 Windows 笔记本电脑上设置一个开发环境,当我收到你的建议时(遇到与 user2603293 相同的问题)并且你说服我去虚拟盒子路线。让一切正常工作是相当困难的,我从经验中知道 Linux 环境对 Rails 开发有多友好。
      猜你喜欢
      • 1970-01-01
      • 2014-12-15
      • 2017-10-20
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2015-05-31
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多