In my case, I only get the the first file in the AppData plugins folder loaded. This is incorrect behavior since each file has a unique path even though they have the same basename.
No sorry JIm, your conclusion is incorrect.
Simply read the description for Kernel.require.
(1) The first file found is loaded.
(2) The userâs %AppData% path has precedence over the %ProgramData% path.
(The user may wish to copy a script from the latter into their own âPluginsâ folder, and tweak it for personal use. This is very likely to happen in an educational setting.)
So, when specifying relative script paths, it depends upon the order of the basepaths in the $LOAD_PATH array. The userâs âpluginsâ path should come before, the programâs âpluginsâ path.
If you wish a different order, you can change the $LOAD_PATH order on your machine only, but do not expect others to do this.
The usual proper way, (of ignoring the $LOAD_PATH order,) is to specify an absolute script path as the argument to Kernel.require.
If you were thinking that because the first âa.rbâ has already been loaded, that Kernel.require should continue searching for another to load, that is incorrect. If it finds that the argument path has already been loaded, (by checking the $LOADED_FEATURES array,) an finds a member that has the argument as part of the pathstring, then it returns false, and does no search.
You would need to provide a more specific path argument to Kernel.require, that would not match the first âa.rbâ but would match the second in %ProgramData%.
Well, it is not my code. This is SketchUp that loads all the appropriate files in these two folders. So SketchUp is not using the full path when it requires them which is why, as Dan explained, the second a.rb is not loaded. The second a.rb file resolves to the same path as the first and is not loaded because that path already exists in $LOADED_FEATURES.
So that means that your âloaderâ code file needs to explicitly load those two files from their paths, rather than let Sketchup require them as it startsâŚ
If they are in subfolders they wonât auto-load at all, only the loader will.
I find it hard to imagine why youâd actually want to have two files with the exact same name loading from different locations ?
If their contents are different give them different names, if theit contents are the same why worry when one doesnât load ?
Presumably the ProgramData one is put there by an Installer, whilst the Roaming one is installed from an RBZ automatically vis Preferences ?
If you actually want both loading whatâs wrong with having them named differently say a.rb and a_.rb ?