Ruby “require” statement

Question:

I am evaluating your product for ruby on windows xp and followed the quick start and unzipped the files into a new directory on my C drive. In my script where it calls for chilkat with the “require chilkat” statement, I get an error that says that gem can’t be found on the system. I tried doing a gem install for chilkat but it can’t find it remotely.

Is there a quick fix to get this to work?

Answer:

This page describes the Ruby require statement in more detail.

In summary:

  1. (This is quoted from the about.com page linked above.) “The require method takes the name of the file to require, as a string, as a single argument. This can either be a path to the file, such as ./lib/some_library.rb or a shortened name, such as some_library. If the argument is a path and complete filename, the require method will look there for the file. However, if the argument is a shortened name, the require method will search through a number of pre-defined directories on your system for that file.”
  2. If a shortened name is used, Ruby searches the directories listed in the $LOAD_PATH environment variable.
Tags :