0

I am new to Ruby. I have Ruby code specifies the location of MyMain.dll, and the functions available. I load MyMain.dll with this call: require_relative "bin64/MyMain"

MyMain.dll in turn relies on Support1.dll, Suport2.dll, etc (actually 80+ support dll files). These files are in bin64/SupportFiles

If I include the SupportFiles folder in the system PATH, everything loads and runs like it should. However, I have been asked to avoid changing the system PATH if at all possible.

Is there a way to tell Ruby the SupportFiles location, or do I need to add a require_relative line for each support dll?

Update: after reading the replies, I have tried each of the options under "load support files", but without the system path, the call to load the main dll still fails:

#Load support files
Dir["bin64/SupportFiles/*.dll"].each {|file| require file }
Dir["bin64/SupportFiles/*.*"].each {|file| require file }
Dir["/bin64/SupportFiles/*.dll"].each {|file| require_relative file }
Dir["/bin64/SupportFiles/*.*"].each {|file| require file }
require_relative "bin64/SupportFiles"

#Load main dll
require_relative "bin64/MyMainDll"
  • Ruby is scripting language, you can write a simple loop over all file sin the directory and call require_relative on each file ;) – Fabio Apr 06 '20 at 04:28
  • Welcome to SO! Check out these answers: 1. https://stackoverflow.com/questions/735073/best-way-to-require-all-files-from-a-directory-in-ruby 2. https://stackoverflow.com/questions/13272971/how-to-call-a-windows-dll-from-within-ruby – Jared Beck Apr 06 '20 at 05:39
  • I guess you are on Windows? You could write a wrapper, which dynamically adds the correct directory to the PATH before running the application. In this case, you don't need to change your system wide PATH settings. – user1934428 Apr 06 '20 at 07:40
  • MyMain.dll is a plugin for SketchUp, and the support dlls are a library I use with other plugins. The user can launch SketchUp many ways so a wrapper to change the path is not an option. – Mary Anne Graham US Apr 06 '20 at 14:08

0 Answers0