error when requiring rubygems with ruby 1.8.6 with windows 7

760 Views Asked by At

There were some cases before in previous questions but their answers weren't useful for me because I'm using Windows 7 and they are using MAC or Linux.

Here are some details about my Ruby installation:

C:\Ruby\rubygems-1.3.1>gem env

RubyGems Environment:

  RUBYGEMS VERSION: 1.3.1
  RUBY VERSION: 1.8.6 (2008-08-11 patchlevel 287) [i386-mswin32]
  INSTALLATION DIRECTORY: C:/Ruby/lib/ruby/gems/1.8
  RUBY EXECUTABLE: C:/Ruby/bin/ruby.exe
  EXECUTABLE DIRECTORY: C:/Ruby/bin
  RUBYGEMS PLATFORMS:
    ruby
    x86-mswin32-60
  GEM PATHS:
     C:/Ruby/lib/ruby/gems/1.8
     C:/Users/Omar H/.gem/ruby/1.8
  GEM CONFIGURATION:
     :update_sources => true
     :verbose => true
     :benchmark => false
     :backtrace => false
     :bulk_threshold => 1000
     :sources => ["http://production.s3.rubygems.org/"]
  REMOTE SOURCES:
     http://production.s3.rubygems.org/

I'm trying to use the JSON gem, so here is how my code starts:

require 'rubygems'
require 'json/pure'

The code is for a sketchup plugin. Whenever I open sketchup and sketchup tries to load this file, I get this error:

Error Loading File addAtt.rb
no such file to load -- rubygems

I looked into the directory where gems are supposed to be installed and found the gem there: C:\Ruby\lib\ruby\gems\1.8\gems.

I've even checked that I'm not missing the libzlib-ruby or libyaml-ruby files since that was also one of the reasons that I saw that may had caused this problem, but I do have these files.

This attempt was to use the json-pure gem.,, which I have installed.

I know that Sketchup when installed doesn't install the full ruby library, and that's why I have downloaded the rest of the ruby files needed and do satisfy the ruby version for Sketchup from this link: http://rubyforge.org/frs/download.php/47082/ruby186-27_rc2.exe. Maybe the reason for my problem may be that I'm having more than one ruby versions and files of other versions are used instead, but I don't know how to find out that or fix it.

@Sachin Singh I tried to use the gem update --system command, and here is what happened:

C:\Users\Omar H>gem update --system
Updating RubyGems
Updating rubygems-update
ERROR:  While executing gem ... (Gem::InstallError)
    rubygems-update requires Ruby version >= 1.8.7
1

There are 1 best solutions below

1
On

I believe you need to add the standard library paths to $LOAD_PATH. That's how Ruby will know where to find 'rubygems'. SketchUp does not add any library paths in $LOAD_PATH by default.