From: Phillip Gawlowski Date: 2011-01-07T00:56:19+09:00 Subject: Re: Exception 'LoadError' everywhere On Thu, Jan 6, 2011 at 3:57 PM, Samuel Slayden wrote: > Hi folks, > > I am a total Ruby noob, so please forgive my ignorance. No worries. :) > Background - A previous co-worker wrote some handy Ruby scripts to > process some spreadsheets. Ruby environment (Windows) was loaded on his > computer and all ran well. Co-worker leaves, and his computer is sent to > be refreshed. The environment is lost, but his Ruby scripts were saved > on the network. > > Now - I have attempted to install Ruby and the necessary gems to allow > these nifty scripts to live once again. Unfortunately, I have been > getting several errors when I run in debug (ruby -d). The main error I > am getting is: The problem is that the environment used doesn't exist anymore. Has said coworker, maybe, left notes somewhere about his script? Particularly the versions of Ruby, Roo, and FasterCSV used? However, a little post-mortem: > MergeRead.rb:40: warning: shadowing outer local variable - row This is an error telling you that a block variable is already used as a local variable. This is a hint that your coworker used a version of Ruby that wasn't 1.9 (so, 1.8.X, most likely), and can, in your script, be fixed by changing the block variable |row| (for example), to something else. Keep in mind that every instance of row has to be replaced. :) > Exception `LoadError' at :29 - no > such file to load -- rubygems/defaults/ruby Ruby 1.9 included RubyGems as part of its standard library, and I guess that the require "rubygems" throws this error. > > Can someone please take a look and give me a little direction? I have > attached the complete debug file as well as the .rb that produced it. Looking at the script: Ruby's CSV has been replaced with FasterCSV, and requiring RubyGems isn't necessary anymore. First, I'd try and see if removing the require "rubygems" and require "fastercsv" already fix the script. You might have to replace require "fastercsv" with just require "csv", though. If you don't want to rewrite the script, you could try installing Ruby 1.8.x (probably 1.8.6 was used), and see if installing RubyGems, FasterCSV, and Roo are enough to make the script run again. Rewriting can be done with Ruby's win32ole[0] support (The Ruby on Windows blog has a few articles related to just that[1]), and CSV. That could be done faster than trying to rebuild an environment by trial and error, I think. HTH! [0] http://ruby-doc.org/stdlib/libdoc/win32ole/rdoc/index.html [1] http://rubyonwindows.blogspot.com/search/label/excel -- Phillip Gawlowski Though the folk I have met, (Ah, how soon!) they forget When I've moved on to some other place, There may be one or two, When I've played and passed through, Who'll remember my song or my face.