ousnius / BodySlide-and-Outfit-Studio

BodySlide and Outfit Studio, a tool to convert, create, and customize outfits and bodies for Bethesda games.
GNU General Public License v3.0
286 stars 63 forks source link

Executables not finding "Setup.xrc" folder despite res folder being in the same directory #486

Closed byjove01 closed 11 months ago

byjove01 commented 1 year ago

Description Everything is in the title.

How to reproduce

  1. Build version 5.6.0 on Arch Linux with cmake and gcc
  2. Correct a weird uint32_t-related compilation-killing error in "BodySlide-and-Outfit-Studio/src/utils/PlatformUtil.h" by putting include <stdint.h> to the top
  3. Put the newly compiled executables and the res folder into the same directory
  4. See error Screenshot_20230522_170715
ousnius commented 1 year ago

@byjove01 What's the path it's trying to load the file from? Can you try putting a debugger breakpoint to see?

byjove01 commented 1 year ago

I am not used to use gdb so I could need some help from you if you want me to manually put a debugger breakpoint. The executable doesn't give me any hint about the path it tries to take the file from.

byjove01 commented 1 year ago

hm..

ousnius commented 1 year ago

I don't have a Linux system and never used GDB, so I'm afraid I can't help you here personally.

byjove01 commented 1 year ago

Built it in debug mode and running the executable gives me that assertion fail output: ASSERT INFO: /usr/src/debug/wxwidgets/wxWidgets-3.2.2.1/src/unix/dir.cpp(284): assert ""IsOpened()"" failed in GetNext(): must wxDir::Open() first

BACKTRACE:
[1] wxDir::GetNext(wxString*) const
[2] wxFindNextFile()
[3] wxLocalFSHandler::FindNext()
[4] wxFileSystem::FindNext()
[5] wxXmlResource::Load(wxString const&)
[6] wxEntry(int&, wchar_t**)
[7] __libc_start_main
ousnius commented 1 year ago

That means it cannot find the "res" folder or there's no permission to open the "res" folder where the "Setup.xrc" file should be located.

byjove01 commented 1 year ago

However, I got all permissions to my "res" folder and the Setup.xrc is in there.

chriku commented 11 months ago

it loads Setup.xrc from the data dir. try strace ./BodySlide 2>&1 |grep -i Setup.xrc to find the path where it is looking

byjove01 commented 11 months ago

output.txt

Here is the output.

chriku commented 11 months ago

What I read from that: /usr/local/share/BodySlide/res/xrc/Setup.xrc is missing. if you want to have bodyslide there, I don't know, but this is where it searches for it.

byjove01 commented 11 months ago
newfstatat(AT_FDCWD, "{working directory path}/share/BodySlide/res/xrc/Setup.xrc", 0x7fff8ed4ade0, 0) = -1 ENOENT (Aucun fichier ou dossier de ce type)
openat(AT_FDCWD, "{working directory path}/share/BodySlide/res/xrc", O_RDONLY|O_NONBLOCK|O_CLOEXEC|O_DIRECTORY) = -1 ENOENT (Aucun fichier ou dossier de ce type)
newfstatat(AT_FDCWD, "{working directory path}/share/BodySlide/res/xrc/Setup.xrc", 0x7fff8ed4aaa0, 0) = -1 ENOENT (Aucun fichier ou dossier de ce type)

Ok, I got the problem now. BodySlide forces its binaries to rely on a hypothetic "share" folder like the one you can find in Linux's root partition ; it would be nice if we could directly configure Cmake to make a relative search so this software could be portable.

ousnius commented 11 months ago

@byjove01 This is caused by the BodySlide code calling GetDataDir() in the standard paths class: https://github.com/ousnius/BodySlide-and-Outfit-Studio/blob/dev/src/program/BodySlideApp.cpp#L111 https://github.com/wxWidgets/wxWidgets/blob/master/src/unix/stdpaths.cpp#L230

On Windows this is where the application is installed (where the executable resides): https://github.com/wxWidgets/wxWidgets/blob/master/src/msw/stdpaths.cpp#L318

This was done to prevent BodySlide trying to load the resource files from the working directory.