pkg2appimage icon indicating copy to clipboard operation
pkg2appimage copied to clipboard

Issues bundling Mono apps

Open darealshinji opened this issue 7 years ago • 3 comments

Using this yaml script to build an AppImage results in an error when I try to run it:

$ ./gMKVExtractGUI-2.2.0.glibc2.15-x86_64.AppImage 
Can't find custom attr constructor image: /tmp/.mount_gMKVEx7S14Xx/usr/lib/mono/exe/gMKVExtractGUI.exe mtoken: 0x0a000001
Unhandled loader error: 8, (null) System.Core, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 (null)
* Assertion: should not be reached at loader.c:298

Stacktrace:


Native stacktrace:

	mono() [0x49ff2f]
	/lib/x86_64-linux-gnu/libpthread.so.0(+0x12890) [0x7f1b55d7e890]
	/lib/x86_64-linux-gnu/libc.so.6(gsignal+0xc7) [0x7f1b559b9e97]
	/lib/x86_64-linux-gnu/libc.so.6(abort+0x141) [0x7f1b559bb801]
	mono() [0x630409]
	mono() [0x63069c]
	mono() [0x630833]
	mono() [0x54357a]
	mono() [0x54641b]
	mono() [0x546796]
	mono() [0x546d80]
	mono(mono_get_method_full+0x23) [0x546ee3]
	mono() [0x41543a]
	mono() [0x415476]
	mono() [0x4494fb]
	mono() [0x500b39]
	mono() [0x501fbd]
	mono() [0x425db6]
	mono() [0x426749]
	mono(mono_runtime_invoke+0x3d) [0x5ac68d]
	mono(mono_runtime_exec_main+0xbc) [0x5ae9cc]
	mono(mono_main+0x1177) [0x476967]
	/lib/x86_64-linux-gnu/libc.so.6(__libc_start_main+0xe7) [0x7f1b5599cb97]
	mono(_start+0x29) [0x422e79]

Debug info from gdb:

Fatal Python error: Py_Initialize: Unable to get the locale encoding
ModuleNotFoundError: No module named 'encodings'

Current thread 0x00007fe4b142bb00 (most recent call first):

=================================================================
Got a SIGABRT while executing native code. This usually indicates
a fatal error in the mono runtime or one of the native libraries 
used by your application.
=================================================================

Aborted (core dumped)

But when I use mkbundle to find out the dependencies and bundle only what's really needed it works. It runs on Ubuntu 18.04 where I have no Mono installed at all. The result is also smaller. Here's the script I use: https://gist.github.com/darealshinji/13229b256f61c4fc7aa8ec0459779ddc

By the way using mkbundle to generate a bundled app gives me runtime errors too.

darealshinji avatar May 30 '18 19:05 darealshinji

I am confused. Is this a mono or a python error? Fatal

Python error: Py_Initialize: Unable to get the locale encoding
ModuleNotFoundError: No module named 'encodings'

reads like that module is not on the $PYTHONPATH (e.g., usr/share/pyshared/)...

probonopd avatar May 31 '18 05:05 probonopd

I don't even know what python is need here for. It turns out I can use monodis to get the dependencies of a mono app. Here's a script that does something similar to the copy_deps function and it also bundles the minimum mono runtime required to run the app: mono-simple-bundle.sh

I've updated the gMKVExtractGUI recipe accordingly.

darealshinji avatar May 31 '18 11:05 darealshinji

This issue is due to that the env variables PYTHONHOME and PYTHONPATH are set by the AppRun executable.

daiyam avatar Jul 23 '21 09:07 daiyam