With only my addon loaded, this line throws the mystifying exception function expected instead of nil. I say mystifying because if LibStub is not defined then the exception I would expect is attempt to call local/global LibStub (a nil value). I can make the untrapped exception go away by wrapping the assignment in a pcall() but all that does is silence the message.
With LibAddonMenu-2.0 loaded (or any other add-on that uses it) then everything works as expected. So it appears that this bit of the addon has all along been been working only by accident because some other addon had already successfully loaded the library I want.
My question is, what could I be doing wrong? My instincts suggest a typo, but if it is, I just can't see it. There are only 2 lines of code to look at, and 16 filenames to check (LibStub, LibAddonMenu and its 14 controls). Here they are:
Thank you. I didn't know that the order of the modules in the .txt file was significant. So it was a typo, of a sort.
The order of the files in the.txt determines the load order of the files. When a file is loaded it'll run all the code there. If some code is within a function, unless the function is called it won't be run, but the function will be created. The event for add-on initialized is fired anytime an add-ons files are all loaded. Thus, you can put the LibStub file inside that and it won't matter where in the manifest libstuf is.