overextended / ox_lib

A FiveM resource and script library for Lua and JS.
https://overextended.dev/ox_lib
GNU Lesser General Public License v3.0
302 stars 403 forks source link

[Bug] require bug when ox_lib is loaded more than once #545

Closed whyauthentic closed 5 months ago

whyauthentic commented 5 months ago

Describe the bug ox_inventory isn't working with the newest ox_lib Version

To Reproduce Steps to reproduce the behavior:

  1. Update ox_lib to the newest Version
  2. Restart your Server
  3. Join your Server
  4. See error on Client Side

Expected behavior Normal Loading and Function from ox_inventory

Screenshots image

Manason commented 5 months ago

I am also seeing errors, affecting other resources as well.

thelindat commented 5 months ago

image

glm isn't even technically loaded by ox_lib; the first package searcher/loader is the standard require function provided by cfx.

https://github.com/overextended/ox_lib/blob/master/imports/require/shared.lua#L94-L100

Manason commented 5 months ago

Here are some of the errors I'm newly seeing after updating ox_lib

https://cdn.discordapp.com/attachments/1227387291266453615/1227387291551531058/image.png?ex=6628387e&is=6615c37e&hm=d3ea32e48015a3f86dba6a258b18c3b394748d75f1f208b9ebb203e0ab9eff0f&

https://cdn.discordapp.com/attachments/1211208527822192670/1226369658182045816/image.png?ex=662484bf&is=66120fbf&hm=e662e866c33905bba761bc8b2e928519bcaf0a9e1f8401f247b9e6c03fb5d7c6&

https://cdn.discordapp.com/attachments/1118364689588572170/1227385556564967494/image.png?ex=662836e0&is=6615c1e0&hm=de93534cab82106fd9e3045daf44dcb36bb0deb795e439878f74168234aacd86&

xPiwel commented 5 months ago

Same issue here since 3.19.0 (not fixed with 3.19.1). Works fine with 3.18.0

image

Envi-Scripts commented 5 months ago

Can also confirm the same issue. One thing I notice is that I cannot find the ox_lib/imports/require/client.lua in the resource anywhere and there is only a shared.lua inside that folder

image

Manason commented 5 months ago

Can also confirm the same issue. One thing I notice is that I cannot find the ox_lib/imports/require/client.lua in the resource anywhere and there is only a shared.lua inside that folder

image

The client.lua is not there in v3.18.0 https://github.com/overextended/ox_lib/tree/e3ece4f337bef61a19dca7bca5a6f61b73a3d72d/imports/require so it would not be related to this bug as the issues here are reproducible in v3.19 only

thelindat commented 5 months ago

the issues here are reproducible

Our definitions of "reproducible" are clearly very different.

The images you posted aren't even related to the issue being reported; one of them doesn't even reference ox_lib, and two of them are waitFor timeout errors due to you having too many assets loaded and failing to load more.

thelindat commented 5 months ago

Freshly installed ESX-Ox recipe does not have the reported issue either.

image

Changing the name of the module being loaded to specifically invoke an error also gives a different (and expected) error message.

[ 323141] [b3095_GTAProce] UV loop: httpClient/ Required resources: ox_inventory [ 323156] [b3095_GTAProce] MainThrd/ Creating script environments for ox_inventory [ 323172] [b3095_GTAProce] MainThrd/ ^5[ox_inventory] ^3[WARN] ox_lib's class module is experimental and may break without warning.^7 [ 323172] [b3095_GTAProce] MainThrd/ ^1SCRIPT ERROR: @ox_lib/imports/require/client.lua:179: module 'glmerr' not found [ 323172] [b3095_GTAProce] MainThrd/ no field package.preload['glmerr'] [ 323172] [b3095_GTAProce] MainThrd/ no file '@ox_lib/glmerr.lua' [ 323172] [b3095_GTAProce] MainThrd/ no file '@ox_lib/glmerr/init.lua'^7 [ 323172] [b3095_GTAProce] MainThrd/ ^3> require^7 (^5@ox_lib/imports/require/client.lua^7:179) [ 323172] [b3095_GTAProce] MainThrd/ ^3> fn^7 (^5@ox_lib/imports/zones/client.lua^7:1) [ 323172] [b3095_GTAProce] MainThrd/ ^3> loadModule^7 (^5@ox_lib/init.lua^7:54) [ 323172] [b3095_GTAProce] MainThrd/ ^3> index^7 (^5@ox_lib/init.lua^7:69) [ 323172] [b3095_GTAProce] MainThrd/ ^3> ref^7 (^5@ox_target/client/api.lua^7:28) [ 323172] [b3095_GTAProce] MainThrd/ ^3> createCraftingBench^7 (^5@ox_inventory/modules/crafting/client.lua^7:57) [ 323172] [b3095_GTAProce] MainThrd/ ^3> result^7 (^5@ox_inventory/modules/crafting/client.lua^7:99) [ 323172] [b3095_GTAProce] MainThrd/ ^3> require^7 (^5@ox_lib/imports/require/client.lua^7:170) [ 323172] [b3095_GTAProce] MainThrd/ ^3> result^7 (^5@ox_inventory/client.lua^7:112) [ 323172] [b3095_GTAProce] MainThrd/ ^3> require^7 (^5@ox_lib/imports/require/client.lua^7:170) [ 323172] [b3095_GTAProce] MainThrd/ ^3> fn^7 (^5@ox_inventory/init.lua^7:196) [ 323172] [b3095_GTAProce] MainThrd/ ^1SCRIPT ERROR: @ox_inventory/modules/crafting/client.lua:57: [ 323172] [b3095_GTAProce] MainThrd/ ^5 An error occurred while calling export addBoxZone in resource ox_target: [ 323172] [b3095_GTAProce] MainThrd/ nil [ 323172] [b3095_GTAProce] MainThrd/ ^5 ---^7

Yours somehow shows the field package and no file lines twice.

thelindat commented 5 months ago

Normal Loading and Function from ox_inventory

As shown in your stack trace the error is in ox_target and not ox_inventory; it's also only an issue in older versions of ox_target and was fixed with v1.14.0.