"Cannot find a library instance of ..." - ESOUI
Thread Tools Display Modes
06/18/17, 12:00 AM   #1
AddOn Author - Click to view addons
Join Date: Aug 2016
Posts: 17
"Cannot find a library instance of ..."


I've played around with some own addons and I just got familiar with LibAddonMenu-2.0 library. On Wiki there were some great instructions and I learned a lot how to use it.

But I don't really understand why two other libraries does not work whatsoever. I'm trying to use LibScroll and libChat2. So here's what I've done:
  • I've extracted LibScroll and libChat2 folders inside my addon's folder (just like I did with LibAddonMenu-2.0)
  • Neither of them adviced to list them into DependsOn or OptionalDependsOn lists inside the manifest so at first I didn't. But because I haven't been able to make it work I've tried in both of them. Problem's still there.
  • I have them listed in my manifest file in a same way I have LibAddonMenu-2.0 (and LibStub) but no luck so far. One thing I do not understand is I don't have LibAddonMenu-2.0 (and LibStub) folders inside any folder called "Libs" but in Lua you have to write that before - why's that? For example, "Libs/LibStub/LibStub.lua" when the path is really "...\AddOns\<ADDON>\LibStub\LibStub.lua"

In my LUA I have the following code (in the very beginning of the file):

local LibAM = LibStub:GetLibrary("LibAddonMenu-2.0")
local LibS = LibStub:GetLibrary("LibScroll")
local LibC = LibStub:GetLibrary("libChat-1.0")
And no matter what I've tried I still get the error from LibScroll and libChat-1.0. LibAddonMenu-2.0 is working fine, though, and I've managed to create an addon settings page which is working as intended.

Any help here?
  Reply With Quote
06/18/17, 01:10 AM   #2
votan's Avatar
AddOn Author - Click to view addons
Join Date: Oct 2014
Posts: 520
There is nothing special with libraries. They are just Lua code as everything else.
Means: The load order matters. => Something, not declared yet, is unknown.

In your manifest LibStub must come first, then all libs you want to use and last comes your main file using them.
Typos in paths are silently ignored.

Show us your manifest.txt.
@votan73 (EU - megaserver)
  Reply With Quote
06/18/17, 01:28 AM   #3
AddOn Author - Click to view addons
Join Date: Aug 2016
Posts: 17
Problem solved, thanks votan!

Did not know and nobody ever mentioned it anywhere that you must load libraries before your own LUA and XML files. Did not think the load order matters.
  Reply With Quote
09/07/20, 12:14 PM   #4
Join Date: Sep 2020
Posts: 1
If you are a simple user from 2020 and have same problem, for example
"user:/AddOns/GearSetsSort/GearSetsSort.lua:328: Cannot find a library instance of "LibAddonMenu-2.0".

where is a fix:

change line in GearSetsSort.lua file
from " local LAM = LibStub('LibAddonMenu-2.0') " to "local LAM = LibAddonMenu2".
  Reply With Quote
09/08/20, 06:08 AM   #5
Baertram's Avatar
AddOn Author - Click to view addons
Join Date: Mar 2014
Posts: 3,095
Additional information about libraries can be read here, especially why LibStub is obsolete meanwhile and should not be used anymore (where not needed):
  Reply With Quote

ESOUI » Developer Discussions » Lua/XML Help » "Cannot find a library instance of ..."

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off