Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Loading error] Error with Eradicator's L.I.B.R.A.R.Y. #199

Open
sproott opened this issue Jan 23, 2023 · 1 comment
Open

[Loading error] Error with Eradicator's L.I.B.R.A.R.Y. #199

sproott opened this issue Jan 23, 2023 · 1 comment
Labels
bug Something isn't working

Comments

@sproott
Copy link

sproott commented Jan 23, 2023

I'm using YAFC version 0.5.8 from FlatHub and Factorio version 1.1.76.

When loading YAFC with just Eradicator's L.I.B.R.A.R.Y., it crashes with the following error:

Require base/prototypes/equipment.lua
Require base/prototypes/legacy/legacy-entities.lua
Require base/prototypes/custom-inputs.lua
Require base/menu-simulations/menu-simulations.lua
Executing base/data-updates.lua
Executing eradicators-library/data-final-fixes.lua
Require eradicators-library/erlib/empty.lua
Require eradicators-library/erlib/shared.lua
Require 00-toggle-to-enable-dev-mode/empty.lua
Unhandled exception. System.Collections.Generic.KeyNotFoundException: The given key '00-toggle-to-enable-dev-mode' was not present in the dictionary.
   at System.Collections.Generic.Dictionary`2.get_Item(TKey key)
   at YAFC.Parser.FactorioDataSource.ReadModFile(String modName, String path) in /app/yafc/YAFCparser/FactorioDataSource.cs:line 67
   at YAFC.Parser.LuaContext.Require(IntPtr lua) in /app/yafc/YAFCparser/LuaContext.cs:line 351
   at YAFC.Parser.LuaContext.lua_pcallk(IntPtr state, Int32 nargs, Int32 nresults, Int32 msgh, IntPtr ctx, IntPtr k)
   at YAFC.Parser.LuaContext.Exec(ReadOnlySpan`1 chunk, String mod, String name, Int32 argument) in /app/yafc/YAFCparser/LuaContext.cs:line 408
   at YAFC.Parser.LuaContext.Require(IntPtr lua) in /app/yafc/YAFCparser/LuaContext.cs:line 353
   at YAFC.Parser.LuaContext.lua_pcallk(IntPtr state, Int32 nargs, Int32 nresults, Int32 msgh, IntPtr ctx, IntPtr k)
   at YAFC.Parser.LuaContext.Exec(ReadOnlySpan`1 chunk, String mod, String name, Int32 argument) in /app/yafc/YAFCparser/LuaContext.cs:line 408
   at YAFC.Parser.LuaContext.DoModFiles(String[] modorder, String fileName, IProgress`1 progress) in /app/yafc/YAFCparser/LuaContext.cs:line 436
   at YAFC.Parser.FactorioDataSource.Parse(String factorioPath, String modPath, String projectPath, Boolean expensive, IProgress`1 progress, ErrorCollector errorCollector, String locale, Boolean renderIcons) in /app/yafc/YAFCparser/FactorioDataSource.cs:line 287
   at YAFC.WelcomeScreen.LoadProject() in /app/yafc/YAFC/Windows/WelcomeScreen.cs:line 302
Fatal error. Internal CLR error. (0x80131506)
   at YAFC.Parser.LuaContext.lua_pcallk(IntPtr, Int32, Int32, Int32, IntPtr, IntPtr)
   at YAFC.Parser.LuaContext.lua_pcallk(IntPtr, Int32, Int32, Int32, IntPtr, IntPtr)
   at YAFC.Parser.LuaContext.Exec(System.ReadOnlySpan`1<Byte>, System.String, System.String, Int32)
   at YAFC.Parser.LuaContext.Require(IntPtr)
   at YAFC.Parser.LuaContext.lua_pcallk(IntPtr, Int32, Int32, Int32, IntPtr, IntPtr)
   at YAFC.Parser.LuaContext.lua_pcallk(IntPtr, Int32, Int32, Int32, IntPtr, IntPtr)
   at YAFC.Parser.LuaContext.Exec(System.ReadOnlySpan`1<Byte>, System.String, System.String, Int32)
   at YAFC.Parser.LuaContext.DoModFiles(System.String[], System.String, System.IProgress`1<System.ValueTuple`2<System.String,System.String>>)
   at YAFC.Parser.FactorioDataSource.Parse(System.String, System.String, System.String, Boolean, System.IProgress`1<System.ValueTuple`2<System.String,System.String>>, YAFC.Model.ErrorCollector, System.String, Boolean)
   at YAFC.WelcomeScreen+<LoadProject>d__32.MoveNext()
... the rest of the stacktrace

I tried to investigate a bit myself, but I couldn't really make much out of this, just that the mod does some interesting stuff with running require on 00-toggle-to-enable-dev-mode, which seems to be a small utility mod that you can install by copying it into your mods folder (see this subdir). Nonetheless, it works in Factorio but crashes YAFC.

Here's a save file to sync mods.

@sproott sproott added the bug Something isn't working label Jan 23, 2023
DaleStan referenced this issue in DaleStan/yafc Jan 24, 2023
pcall(require, '__nonexistent-mod__/file') doesn't fail in a way that Lua can handle.
@DaleStan
Copy link
Contributor

I can't figure out what Eradicator's doing either. I believe I found an issue with YAFC's handling of pcall(require, ...), but that isn't the only problem here.

Until someone smarter can figure out how to fix it properly: (1) replace the two calls to does_file_exist in shared.lua with false, and (2) on line 346 of erlib/factorio/Stacktrace.lua, replace flag.IS_FACTORIO with false. I don't know if/how this will mess up anyone using erlib, though.

ShadowTheAge: I tried making FactorioDataSource.ReadModFile return null when it intercepted pcall(require, '__00-toggle-to-enable-dev-mode__/empty'), but I couldn't figure out how to get pcall to return false.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants