Why do I get weird problems with libraries

This could be because you have specified a relative path in the library path ('.' for example, as in ruby -I. script.rb) and have changed the working directory somewhere in the script. There are basically one workaround and one solution to this problem, the workaround is simply to specify an absolute path instead of the relative path. The solution is to use the with_working_dir method (in the FileUtils module) instead of changing the directory with Dir.chdir, the with_working_dir restores the previous working directory before it exits. Like this:

require 'damagecontrol/util/FileUtils'
include FileUtils

with_working_dir("somedirectory") do
  # ... trut your stuff ...
end

Labels

 
(None)