Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Error "invalid switch in RUBYOPT: -F (RuntimeError)" is shown while install gems by gem install mechanize

Tags:

ruby

rubygems

I'm tried to install gem (mechanize) on my computer by following commands:

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

The error

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)

is shown while I trying to install gems (mechanize). And run command line as Administrator.

I'v installed the DevKit by the commands below (config.xml has been modified of cause)

ruby dk.rb init
ruby dk.rb install

Is there any method can fix this error? Thanks in advance.

Here some OS information:

  • OS Version: Win7 64bit
  • Ruby version: 2.0.0p195 x64
  • DevKit version: DevKit-mingw64-64-4.7.2-20130224-1432-sfx
  • GEM Version: 2.0.3
  • Ruby installed location: C:/Program Files/Ruby200-x64

The details can be found from screenshot: enter image description here

According the Troubleshooting, I'v remove the AutoRun from Regedit (HKCU\Software\Microsoft\Command Processor), but it still cannot work!

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.

Here details about gem and ruby:

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/
like image 810
Marslo Avatar asked Jun 03 '13 13:06

Marslo


1 Answers

I found the reason. Just because there is a space in the installation path of Ruby

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

Re-install the Ruby to the path which doesn't contain space, this error will be fixed.


And, of course, AutoRun should be removed from HKCU\Software\Microsoft\Command Processor and HKLM\Software\Microsoft\Command Processor.

That's important!

like image 141
Marslo Avatar answered Oct 07 '22 06:10

Marslo