6

我试图通过以下命令在我的计算机上安装 gem (mechanize):

>> gem install mechanize --platform=ruby
>> gem install mechanize

错误

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

    "C:/Program Files/Ruby200-x64/bin/ruby.exe" extconf.rb
C:/Program Files/Ruby200-x64/bin/ruby.exe: invalid switch in RUBYOPT: -F (RuntimeError)

在我尝试安装 gem(机械化)时显示。并以管理员身份运行命令行。

我已经通过以下命令安装了DevKit(config.xml 已被修改)

ruby dk.rb init
ruby dk.rb install

有什么方法可以解决这个错误吗?提前致谢。

这里有一些操作系统信息:

  • 操作系统版本:Win7 64bit
  • 红宝石版本:2.0.0p195 x64
  • DevKit 版本:DevKit-mingw64-64-4.7.2-20130224-1432-sfx
  • 创业板版本:2.0.3
  • Ruby 安装位置:C:/Program Files/Ruby200-x64

可以从截图中找到详细信息: 在此处输入图像描述

根据疑难解答,我从 Regedit (HKCU\Software\Microsoft\Command Processor)中删除了 AutoRun,但它仍然无法工作!

2013/06/03 10:00:26 PM >> REG QUERY "HKCU\Software\Microsoft\Command Processor"

HKEY_CURRENT_USER\Software\Microsoft\Command Processor
    CompletionChar    REG_DWORD    0x9
    DefaultColor    REG_DWORD    0x0
    EnableExtensions    REG_DWORD    0x1
    PathCompletionChar    REG_DWORD    0x9
    AutoRun    REG_SZ    (if %ANSICON_VER%==^%ANSICON_VER^% "C:\Marslo\Tools\Software\System\CommandLi
icon" -p)&run C:\WINDOWS\autorun.cmd
    AutoRun_bak    REG_SZ    (if %ANSICON_VER%==^%ANSICON_VER^% "C:\Marslo\Tools\Software\System\Comma
\ansicon" -p)&chcp 437&run C:\WINDOWS\autorun.cmd

2013/06/03 10:01:00 PM >> REG QUERY "HKLM\Software\Microsoft\Command Processor" /s

HKEY_LOCAL_MACHINE\Software\Microsoft\Command Processor
    CompletionChar    REG_DWORD    0x40
    DefaultColor    REG_DWORD    0x0
    EnableExtensions    REG_DWORD    0x1
    PathCompletionChar    REG_DWORD    0x40
    AutoRun    REG_SZ    %WINDIR%\run.bat

2013/06/03 10:01:05 PM >> REG DELETE "HKCU\Software\Microsoft\Command Processor" /v AutoRun
Delete the registry value AutoRun (Yes/No)? yes
The operation completed successfully.

这里有关宝石和红宝石的详细信息:

2013/06/03 10:15:46 PM >> gem env
RubyGems Environment:
  - RUBYGEMS VERSION: 2.0.3
  - RUBY VERSION: 2.0.0 (2013-05-14 patchlevel 195) [x64-mingw32]
  - INSTALLATION DIRECTORY: C:/Program Files/Ruby200-x64/lib/ruby/gems/2.0.0
  - RUBY EXECUTABLE: "C:/Program Files/Ruby200-x64/bin/ruby.exe"
  - EXECUTABLE DIRECTORY: C:/Program Files/Ruby200-x64/bin
  - RUBYGEMS PLATFORMS:
    - ruby
    - x64-mingw32
  - GEM PATHS:
     - C:/Program Files/Ruby200-x64/lib/ruby/gems/2.0.0
     - C:/Users/jiaoolii/.gem/ruby/2.0.0
  - GEM CONFIGURATION:
     - :update_sources => true
     - :verbose => true
     - :backtrace => false
     - :bulk_threshold => 1000
  - REMOTE SOURCES:
     - https://rubygems.org/
4

1 回答 1

19

我找到了原因。只是因为Ruby的安装路径有空格

RUBY EXECUTABLE: "C:/Program Files/Ruby200-x64/bin/ruby.exe"

将 Ruby 重新安装到不包含空格的路径,此错误将得到修复。


而且,当然,AutoRun应该从HKCU\Software\Microsoft\Command Processorand中删除HKLM\Software\Microsoft\Command Processor

这很重要!

于 2013-06-08T07:56:14.173 回答