Skip to content

[Baldur's Gate 3]: Various bug fixes#193

Merged
Holt59 merged 6 commits intoModOrganizer2:masterfrom
TheForgotten69:bugfix/bg3-plugin-fixes
Sep 15, 2025
Merged

[Baldur's Gate 3]: Various bug fixes#193
Holt59 merged 6 commits intoModOrganizer2:masterfrom
TheForgotten69:bugfix/bg3-plugin-fixes

Conversation

@TheForgotten69
Copy link
Contributor

@TheForgotten69 TheForgotten69 commented Sep 10, 2025

Hi there!
Just began to use this plugin and it's great. Lots of great ideas and features from @daescha thanks! But there are a couple of bugs at the moment that are addressed in this MR:

  1. Missing libraries from LSLib: the automatic download works fine but not all mandatory DLLs are extracted
    Current error:
[2025-09-10 14:03:35.967 W] [pak_parser.py:206] D:\Games\Modding\MO2\plugins\data\Baldur's Gate 3 Plugin\tools\Divine.exe -g bg3 -l info -a extract-single-file -f meta.lsx -d "D:\Games\Modding\MO2\plugins\data\Baldur's Gate 3 Plugin\temp\extracted_metadata\Mod Configura-bd40b.lsx" -s "G:\Modding\Baldur's gate 3\mods\Mod Configuration Menu (MCM)\Mod Configuration Menu.pak" returned stdout: [FATAL] Failed to list package: Could not load file or assembly 'K4os.Compression.LZ4.Streams, Version=1.3.8.0, Culture=neutral, PublicKeyToken=2186fa9121ef231d'. The system cannot find the file specified.

  1. Regex issue with mod names (Such as Animate Dead++)
    Current error:
[2025-09-10 13:54:43.494 W] [pak_parser.py:206] D:\Games\Modding\MO2\plugins\data\Baldur's Gate 3 Plugin\tools\Divine.exe -g bg3 -l info -a list-package --use-regex -x "(/Animate Dead++ Spell List Addon/(?!meta\.lsx))|(Public/Engine/Timeline/MaterialGroups)" -s "G:\Modding\Baldur's gate 3\mods\Spell List Addon\PAK_FILES\Animate Dead++ Spell List Addon.pak" returned stdout: [FATAL] Cannot parse RegEx expression: (/Animate Dead++ Spell List Addon/(?!meta\.lsx))|(Public/Engine/Timeline/MaterialGroups)
[2025-09-10 13:54:43.519 W] [pak_parser.py:206] D:\Games\Modding\MO2\plugins\data\Baldur's Gate 3 Plugin\tools\Divine.exe -g bg3 -l info -a list-package --use-regex -x "(/Animate Dead++/(?!meta\.lsx))|(Public/Engine/Timeline/MaterialGroups)" -s "G:\Modding\Baldur's gate 3\mods\Animate Dead Plus Plus\PAK_FILES\Animate Dead++.pak" returned stdout: [FATAL] Cannot parse RegEx expression: (/Animate Dead++/(?!meta\.lsx))|(Public/Engine/Timeline/MaterialGroups)

  1. Logs folder not automatically created
    Current error:
[2025-09-10 13:55:35.544 E] uncaught exception in handler (object startButton, eventtype 3): FileNotFoundError: [WinError 3] The system cannot find the path specified
[2025-09-10 13:55:35.544 E] 
[2025-09-10 13:55:35.544 E] At:
[2025-09-10 13:55:35.544 E]   C:\Python313\\Lib\shutil.py(466): copy2
[2025-09-10 13:55:35.544 E]   C:\Python313\\Lib\shutil.py(876): move
[2025-09-10 13:55:35.544 E]   D:\Games/Modding/MO2/plugins\basic_games\games\game_baldursgate3.py(195): _on_finished_run
[2025-09-10 13:55:35.544 E] 
[2025-09-10 13:55:35.544 E] an error occurred: FileNotFoundError: [WinError 3] The system cannot find the path specified
[2025-09-10 13:55:35.544 E] 
[2025-09-10 13:55:35.544 E] At:
[2025-09-10 13:55:35.544 E]   C:\Python313\\Lib\shutil.py(466): copy2
[2025-09-10 13:55:35.544 E]   C:\Python313\\Lib\shutil.py(876): move
[2025-09-10 13:55:35.544 E]   D:\Games/Modding/MO2/plugins\basic_games\games\game_baldursgate3.py(195): _on_finished_run
  1. File collision issue when generating PAK for Generated mods:
    Current error:
[2025-09-10 14:24:47.427 W] [pak_parser.py:206] D:\Games\Modding\MO2\plugins\data\Baldur's Gate 3 Plugin\tools\Divine.exe -g bg3 -l info -a create-package -d "G:\Modding\Baldur's gate 3\overwrite\Mods\Generated.pak" -s "G:\Modding\Baldur's gate 3\mods\Smaller Torches\Generated" returned stdout: , stderr: Unhandled exception. System.AggregateException: One or more errors occurred. (The process cannot access the file 'G:\Modding\Baldur's gate 3\overwrite\Mods\Generated.pak' because it is being used by another process.)
[2025-09-10 14:24:47.427 W]  ---> System.IO.IOException: The process cannot access the file 'G:\Modding\Baldur's gate 3\overwrite\Mods\Generated.pak' because it is being used by another process.
[2025-09-10 14:24:47.427 W]    at Microsoft.Win32.SafeHandles.SafeFileHandle.CreateFile(String fullPath, FileMode mode, FileAccess access, FileShare share, FileOptions options)
[2025-09-10 14:24:47.427 W]    at Microsoft.Win32.SafeHandles.SafeFileHandle.Open(String fullPath, FileMode mode, FileAccess access, FileShare share, FileOptions options, Int64 preallocationSize, Nullable`1 unixCreateMode)
[2025-09-10 14:24:47.427 W]    at System.IO.Strategies.OSFileStreamStrategy..ctor(String path, FileMode mode, FileAccess access, FileShare share, FileOptions options, Int64 preallocationSize, Nullable`1 unixCreateMode)
[2025-09-10 14:24:47.427 W]    at System.IO.Strategies.FileStreamHelpers.ChooseStrategyCore(String path, FileMode mode, FileAccess access, FileShare share, FileOptions options, Int64 preallocationSize, Nullable`1 unixCreateMode)
[2025-09-10 14:24:47.427 W]    at System.IO.File.Open(String path, FileMode mode, FileAccess access)
[2025-09-10 14:24:47.427 W]    at LSLib.LS.PackageWriter..ctor(PackageBuildData build, String packagePath)
[2025-09-10 14:24:47.427 W]    at LSLib.LS.PackageWriter_V15`2..ctor(PackageBuildData build, String packagePath)
[2025-09-10 14:24:47.427 W]    at LSLib.LS.PackageWriterFactory.Create(PackageBuildData build, String packagePath)
[2025-09-10 14:24:47.427 W]    at LSLib.LS.Packager.CreatePackage(String packagePath, String inputPath, PackageBuildData build)
[2025-09-10 14:24:47.427 W]    --- End of inner exception stack trace ---
[2025-09-10 14:24:47.427 W]    at System.Threading.Tasks.Task.ThrowIfExceptional(Boolean includeTaskCanceledExceptions)
[2025-09-10 14:24:47.427 W]    at System.Threading.Tasks.Task.Wait(Int32 millisecondsTimeout, CancellationToken cancellationToken)
[2025-09-10 14:24:47.427 W]    at System.Threading.Tasks.Task.Wait()
[2025-09-10 14:24:47.427 W]    at Divine.CLI.CommandLinePackageProcessor.CreatePackageResource(String file)
[2025-09-10 14:24:47.427 W]    at Divine.CLI.CommandLinePackageProcessor.Create()
[2025-09-10 14:24:47.427 W]    at Divine.CLI.CommandLineActions.Process(CommandLineArguments args)
[2025-09-10 14:24:47.427 W]    at Divine.CLI.CommandLineActions.Run(CommandLineArguments args)
[2025-09-10 14:24:47.427 W]    at Divine.Program.Main(String[] args)
[2025-09-10 14:24:47.427 W] , code 3762504530
[2025-09-10 14:24:47.445 W] [pak_parser.py:206] D:\Games\Modding\MO2\plugins\data\Baldur's Gate 3 Plugin\tools\Divine.exe -g bg3 -l info -a create-package -d "G:\Modding\Baldur's gate 3\overwrite\Mods\Generated.pak" -s "G:\Modding\Baldur's gate 3\mods\Smaller Flute\Generated" returned stdout: , stderr: Unhandled exception. System.AggregateException: One or more errors occurred. (The process cannot access the file 'G:\Modding\Baldur's gate 3\overwrite\Mods\Generated.pak' because it is being used by another process.)
[2025-09-10 14:24:47.445 W]  ---> System.IO.IOException: The process cannot access the file 'G:\Modding\Baldur's gate 3\overwrite\Mods\Generated.pak' because it is being used by another process.
[2025-09-10 14:24:47.445 W]    at Microsoft.Win32.SafeHandles.SafeFileHandle.CreateFile(String fullPath, FileMode mode, FileAccess access, FileShare share, FileOptions options)
[2025-09-10 14:24:47.445 W]    at Microsoft.Win32.SafeHandles.SafeFileHandle.Open(String fullPath, FileMode mode, FileAccess access, FileShare share, FileOptions options, Int64 preallocationSize, Nullable`1 unixCreateMode)
[2025-09-10 14:24:47.445 W]    at System.IO.Strategies.OSFileStreamStrategy..ctor(String path, FileMode mode, FileAccess access, FileShare share, FileOptions options, Int64 preallocationSize, Nullable`1 unixCreateMode)
[2025-09-10 14:24:47.445 W]    at System.IO.Strategies.FileStreamHelpers.ChooseStrategyCore(String path, FileMode mode, FileAccess access, FileShare share, FileOptions options, Int64 preallocationSize, Nullable`1 unixCreateMode)
[2025-09-10 14:24:47.445 W]    at System.IO.File.Open(String path, FileMode mode, FileAccess access)
[2025-09-10 14:24:47.445 W]    at LSLib.LS.PackageWriter..ctor(PackageBuildData build, String packagePath)
[2025-09-10 14:24:47.445 W]    at LSLib.LS.PackageWriter_V15`2..ctor(PackageBuildData build, String packagePath)
[2025-09-10 14:24:47.445 W]    at LSLib.LS.PackageWriterFactory.Create(PackageBuildData build, String packagePath)
[2025-09-10 14:24:47.445 W]    at LSLib.LS.Packager.CreatePackage(String packagePath, String inputPath, PackageBuildData build)
[2025-09-10 14:24:47.445 W]    --- End of inner exception stack trace ---
[2025-09-10 14:24:47.445 W]    at System.Threading.Tasks.Task.ThrowIfExceptional(Boolean includeTaskCanceledExceptions)
[2025-09-10 14:24:47.445 W]    at System.Threading.Tasks.Task.Wait(Int32 millisecondsTimeout, CancellationToken cancellationToken)
[2025-09-10 14:24:47.445 W]    at System.Threading.Tasks.Task.Wait()
[2025-09-10 14:24:47.445 W]    at Divine.CLI.CommandLinePackageProcessor.CreatePackageResource(String file)
[2025-09-10 14:24:47.445 W]    at Divine.CLI.CommandLinePackageProcessor.Create()
[2025-09-10 14:24:47.445 W]    at Divine.CLI.CommandLineActions.Process(CommandLineArguments args)
[2025-09-10 14:24:47.445 W]    at Divine.CLI.CommandLineActions.Run(CommandLineArguments args)
[2025-09-10 14:24:47.445 W]    at Divine.Program.Main(String[] args)
[2025-09-10 14:24:47.445 W] , code 3762504530

@TheForgotten69 TheForgotten69 marked this pull request as ready for review September 10, 2025 15:13
@daescha
Copy link
Contributor

daescha commented Sep 11, 2025

hi @TheForgotten69! I am very happy someone else got the chance to test this before the next release of MO. All your changes look good!

@Holt59 I recommend merging this, when you get a chance ☺️

as a sidenote: obviously those files from lslib you needed were not needed on my machine. Makes me wonder if there are other ones other people may potentially need... but problem for another day. If you have improvements/criticisms beyond just bug fixes though I would love to hear/see them @TheForgotten69 😌

@TheForgotten69
Copy link
Contributor Author

Hey @daescha I'm happy to test your work! 😊 Honestly, it's the best plugin all around and much better than what's available or even the BG3 mod manager, imo.
I'm especially pleased by the automatic conversion of generated mods to pak!
Regarding LSLib, I guess it might not have all .NET assemblies installed, but yeah I thought of maybe just dumping the whole thing rather than being selective since it's just a few MB, but it's also working for me now that way.
Honestly the plugin is pretty powerful as is, but one potential enhancement might be to list conflicts thanks to LSLib, wdyt? i guess it's possible to store some sort of table where each mod has its pak content associated to compare but you definitely know this more than me. No idea if it's possible in a custom plugin like this but I guess it's pretty niche 🤔

@daescha
Copy link
Contributor

daescha commented Sep 13, 2025

Yeah that would definitely be nice. if you wanted to, you could unpack all your packs into each mod folder and itd show conflicts based on file paths that way - thatd work for files that go in Generated folders at least. Of course the pak loading process in bg3 is not that simple for all the lsf files, they get merged based on xml elements somehow, youd basically have to recreate the games pak loading mechanism to show that part properly.

@Holt59 Holt59 merged commit cae15af into ModOrganizer2:master Sep 15, 2025
3 checks passed
@TheForgotten69 TheForgotten69 deleted the bugfix/bg3-plugin-fixes branch September 15, 2025 13:57
@TheForgotten69
Copy link
Contributor Author

Yeah that could get messy real quick, maybe something that just scans the files within pak and report if it ever find matches? We could have a hash base somewhere in the data plugin folder?
Also just noticed that the "Check for updates" for mods seems to always crash my Mod Organizer instance, have you the same behavior @daescha ?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants