probonopd / linuxdeployqt

Makes Linux applications self-contained by copying in the libraries and plugins that the application uses, and optionally generates an AppImage. Can be used for Qt and other applications
Other
2.2k stars 409 forks source link

libsoftokn3.so issue #35

Open probonopd opened 7 years ago

probonopd commented 7 years ago

When I try to use -bundle-non-qt-libs on a working Otter AppDir or try to convert it to an AppImage, Otter fails to run with

[1022/144633:ERROR:nss_util.cc(740)] Error initializing NSS with a persistent database (sql:/home/me/.pki/nssdb): libsoftokn3.so: cannot open shared object file: No such file or directory
[1022/144633:ERROR:nss_util.cc(211)] Error initializing NSS without a persistent database: NSS error code: -5925
[1022/144633:FATAL:nss_util.cc(213)] nss_error=-5925, os_error=0

The reason for this is to be investigated.

When I delete libnss3.so from the AppDir, then it starts working again.

probonopd commented 7 years ago

Possibly fixed in 2a19bc3, please confirm

g-maxime commented 7 years ago

At last libnssutils3.so, libsmime3.so and libssl3.so depends on it, causing :

/usr/lib64/libnss3.so: version `NSS_3.21' not found (required by ./lib64/libssl3.so)

probonopd commented 7 years ago

Now we have an interesting situation here; recently we ran into an application (Firefox) that refused to run without libnss3.so.

So I am not entirely sure what is the best path of action here.

Reopening the issue. Deleting libnss3.so appears to be the wrong course of action.

probonopd commented 7 years ago

We should check which libraries upstream Firefox bundles, and do the same. (Be sure to carry this over to linuxdeployqt too.)

darealshinji commented 7 years ago

At least on Ubuntu the following libraries are all part of the same libnss3 binary package:

/usr/lib/x86_64-linux-gnu/libnss3.so
/usr/lib/x86_64-linux-gnu/libnssutil3.so
/usr/lib/x86_64-linux-gnu/libsmime3.so
/usr/lib/x86_64-linux-gnu/libssl3.so
/usr/lib/x86_64-linux-gnu/nss/libfreebl3.so
/usr/lib/x86_64-linux-gnu/nss/libfreeblpriv3.so
/usr/lib/x86_64-linux-gnu/nss/libnssckbi.so
/usr/lib/x86_64-linux-gnu/nss/libnssdbm3.so
/usr/lib/x86_64-linux-gnu/nss/libnsssysinit.so
/usr/lib/x86_64-linux-gnu/nss/libsoftokn3.so

I hope that helps to figure out what stuff needs to be bundled or excluded.

probonopd commented 7 years ago

Very good observation @darealshinji - this probably suggests that we should treat all of those together; especially either bundle both libnss3 and libssl3 or neither. We should try both approaches with the Otter AppImage.

probonopd commented 7 years ago

Potentially we could even build some logic/database that would always treat libraries that are part of the same package together...

tamlok commented 6 years ago

@probonopd

Hi,

I also have this problem with VNote. After deleting the libnss3.so and libnssutil3.so in the extracted AppImage, it could run successfully. Then I change the script in travis CI like this:

# Get linuxdeployqt tool
wget -c "https://github.com/probonopd/linuxdeployqt/releases/download/continuous/linuxdeployqt-continuous-x86_64.AppImage"
chmod a+x linuxdeployqt*.AppImage
unset QTDIR; unset QT_PLUGIN_PATH ; unset LD_LIBRARY_PATH
./linuxdeployqt*.AppImage ./dist/usr/share/applications/*.desktop -bundle-non-qt-libs

# Copy translations
cp /opt/qt59/translations/*_zh_CN.qm ./dist/usr/translations/

# Package it for the second time.
./linuxdeployqt*.AppImage ./dist/usr/share/applications/*.desktop -appimage

tree dist/

ls -l *.AppImage

wget "https://github.com/AppImage/AppImageKit/releases/download/continuous/appimagetool-x86_64.AppImage"
chmod a+x appimagetool-x86_64.AppImage

mv VNote-*.AppImage VNote-x86_64.AppImage
chmod a+x VNote-x86_64.AppImage
./VNote-x86_64.AppImage --appimage-extract
rm VNote-x86_64.AppImage
# Delete libnss3.so libnssutil3.so.
rm ./squashfs-root/usr/lib/libnss3.so ./squashfs-root/usr/lib/libnssutil3.so

./appimagetool-x86_64.AppImage squashfs-root

mv VNote-*.AppImage VNote_x86_64_${version}.AppImage

However, the re-packaged AppImage lack the libFcitxQt5DBusAddons.so.1, which seems to exist in the squashfs-root. Append the travis log here.

Any idea to remove the libnss3.so in the AppImage?

Thanks!

probonopd commented 6 years ago

However, the re-packaged AppImage lack the libFcitxQt5DBusAddons.so.1, which seems to exist in the squashfs-root

Are you saying it magically dissapeared when re-packing the AppImage? What did you use to repack? Please use appimagetool to repack an extracted AppImage.

tamlok commented 6 years ago

Yes, the lib disappeared after re-pack. I used appimagetool to pack it. Finally I try the new -exclude-libs option and it works now. Thanks!

forelabs commented 6 years ago

Currently I have the same issue, using Qt 5.9.4 and latest linuxdeploymentqt. But working with -exclude-libs argument seems not to be an option for me, because then my little WebEngine (WebView) component renders also the css in front of the html as plain text, which should not happen.

https://launchpad.net/~beineri/+archive/ubuntu/opt-qt-5.4.9-xenial is missing the libQt5WebView.so, which gets installed by using Qt 5.9.4 from the qt installer.

BTW: When using Qt 5.10.1 it fails with a different error. Currently trying to get around this problem by using an older qt version. Maybe I will open a new issue according the problem in Qt 5.10.1, because using this version without the lib seems not to be a working solution :/

Silex commented 6 years ago

I have the same problem and what is weird is that it appeared recently without touching anything else: builds from january were working fine, and now I have this NSS error.

We are building on 14.04 for historical reasons, maybe libnss was recently upgraded?

My app does not want to start if I delete libnss3.so from the lib directory.

probonopd commented 6 years ago

Check with strace what is actually going on - is it loading /usr/lib/x86_64-linux-gnu/nss/libsoftokn3.so correctly from the system (in case it is a Debian/Ubuntu based system)?

Silex commented 6 years ago

@probonopd: actually it was not!

Using this works:

LD_LIBRARY_PATH="/usr/lib/x86_64-linux-gnu/nss" mybinary

So basically, it'd just be a matter of packaging that lib in the appimage. I'll play around and report.

Silex commented 6 years ago

Ok I just checked based on my latest successful build, and found out that 46a1e7f481317ecfab1804cfe7aa117bcb10e0e6 is able to build & run my Appimage.

I also confirm that using -exclude-libs="libnss3.so,libnssutil3.so" with the latest version fixes the problem.

Silex commented 6 years ago

So after verifications, basically in previous versions it did not package libnss* but it was loaded from the system dir, because it was already installed by 3rd party packages (e.g firefox & friends).

In the latest version, it tries to bundle this dependency but is not complete enough so the loading fails?

Here is the difference between the appimages (I sorted it a bit so it's easier to visualize):

root@P080027f4c1bf ~ # diff -rl squashfs-root-46a1e7f/ squashfs-root-latest/
Binary files squashfs-root-46a1e7f/AppRun and squashfs-root-latest/AppRun differ

Only in squashfs-root-46a1e7f/doc: libatk-bridge2.0-0
Only in squashfs-root-46a1e7f/doc: libatk1.0-0
Only in squashfs-root-46a1e7f/doc: libatspi2.0-0
Only in squashfs-root-46a1e7f/doc: libcairo-gobject2
Only in squashfs-root-46a1e7f/doc: libcairo2
Only in squashfs-root-46a1e7f/doc: libdatrie1
Only in squashfs-root-46a1e7f/doc: libfreetype6
Only in squashfs-root-46a1e7f/doc: libgraphite2-3
Only in squashfs-root-46a1e7f/doc: libgtk-3-0
Only in squashfs-root-46a1e7f/doc: libharfbuzz0b
Only in squashfs-root-46a1e7f/doc: libpixman-1-0
Only in squashfs-root-46a1e7f/doc: libselinux1
Only in squashfs-root-46a1e7f/doc: libthai0
Only in squashfs-root-46a1e7f/doc: libwayland-client0
Only in squashfs-root-46a1e7f/doc: libwayland-cursor0
Only in squashfs-root-46a1e7f/doc: libxinerama1
Only in squashfs-root-46a1e7f/doc: libxkbcommon0
Only in squashfs-root-46a1e7f/doc: libxrandr2
Only in squashfs-root-latest/doc: libk5crypto3

Only in squashfs-root-46a1e7f/lib: libXinerama.so.1
Only in squashfs-root-46a1e7f/lib: libXrandr.so.2
Only in squashfs-root-46a1e7f/lib: libatk-1.0.so.0
Only in squashfs-root-46a1e7f/lib: libatk-bridge-2.0.so.0
Only in squashfs-root-46a1e7f/lib: libatspi.so.0
Only in squashfs-root-46a1e7f/lib: libcairo-gobject.so.2
Only in squashfs-root-46a1e7f/lib: libcairo.so.2
Only in squashfs-root-46a1e7f/lib: libdatrie.so.1
Only in squashfs-root-46a1e7f/lib: libfreetype.so.6
Only in squashfs-root-46a1e7f/lib: libgdk-3.so.0
Only in squashfs-root-46a1e7f/lib: libgraphite2.so.3
Only in squashfs-root-46a1e7f/lib: libgtk-3.so.0
Only in squashfs-root-46a1e7f/lib: libharfbuzz.so.0
Only in squashfs-root-46a1e7f/lib: libpixman-1.so.0
Only in squashfs-root-46a1e7f/lib: libselinux.so.1
Only in squashfs-root-46a1e7f/lib: libthai.so.0
Only in squashfs-root-46a1e7f/lib: libwayland-client.so.0
Only in squashfs-root-46a1e7f/lib: libwayland-cursor.so.0
Only in squashfs-root-46a1e7f/lib: libxkbcommon.so.0
Only in squashfs-root-latest/lib: libk5crypto.so.3
Only in squashfs-root-latest/lib: libnss3.so
Only in squashfs-root-latest/lib: libnssutil3.so

Only in squashfs-root-46a1e7f/plugins: platformthemes

Binary files squashfs-root-46a1e7f/provision_browser and squashfs-root-latest/provision_browser differ
Silex commented 6 years ago

Ok, another fix is doing cp /usr/lib/x86_64-linux-gnu/nss/* lib before building the appimage.

Also it's opened by the app:

stvs@P080027f4c1bf:~/squashfs-root$ strace -f ./AppRun 2>&1 | grep libsoftokn3
[pid  4720] open("/home/stvs/squashfs-root/lib/nss/libsoftokn3.so", O_RDONLY|O_CLOEXEC) = -1 ENOENT (No such file or directory)
[pid  4720] open("/home/stvs/squashfs-root/lib/libsoftokn3.so", O_RDONLY|O_CLOEXEC) = 36

From that I infer that it'd be maybe better to do cp -r /usr/lib/x86_64-linux-gnu/nss lib/ instead.

probonopd commented 6 years ago

Ok, another fix is doing cp /usr/lib/x86_64-linux-gnu/nss/* lib before building the appimage.

Correct, that is the way to do it. linuxdeployqt will only deploy libraries ldd can find on the system.

Unless upstream Qt fixes the principal issue, since it seems their binary distribution does not work properly on Debian/Ubuntu-based system without the above workaround. Did you open a ticket there?

Silex commented 6 years ago

Did you open a ticket there?

No, I didn't know this was a Qt issue.

tsteven4 commented 6 years ago

-exclude-libs="libnss3.so,libnssutil3.so" worked for me on Centos 7. It also worked on Centos 6, but my app crashed on closing which may be unrelated. The equivalent of cp -r /usr/lib/x86_64-linux-gnu/nss lib/ on Centos 6 isn't obvious (/lib64/nss does not exist), on Centos 7 I have yet to try copying /lib64/nss.

tsteven4 commented 6 years ago

On Centos 7 I tried copying /lib64/nss/libnssckbi.so to /lib but it didn't appear to change anything, the error was

[17793:17830:0515/092835.858481:ERROR:nss_util.cc(712)] Error initializing NSS with a persistent database (sql:/home/tsteven4/.pki/nssdb): libsoftokn3.so: cannot open shared object file: No such file or directory [17793:17830:0515/092835.858691:ERROR:nss_util.cc(201)] Error initializing NSS without a persistent database: NSS error code: -5925 [17793:17830:0515/092835.858762:FATAL:nss_util.cc(203)] nss_error=-5925, os_error=0

so I copied /lib64/libsoftokn3.chk & /lib64/libsoftokn3.so to /lib. The error changes to:

[9872:9907:0515/093026.393238:ERROR:nss_util.cc(712)] Error initializing NSS with a persistent database (sql:/home/tsteven4/.pki/nssdb): NSS error code: -8023 [9872:9907:0515/093026.393451:ERROR:nss_util.cc(201)] Error initializing NSS without a persistent database: NSS error code: -8023 [9872:9907:0515/093026.393464:FATAL:nss_util.cc(203)] nss_error=-8023, os_error=0

tsteven4 commented 6 years ago

Unless upstream Qt fixes the principal issue, since it seems their binary distribution does not work properly on Debian/Ubuntu-based system without the above workaround. Did you open a ticket there?

I don't agree, I don't see this as a Qt issue.

The issue seems to arise because of ubuntu libnss3 patch 85_security_load.patch which appeared in the changelogs at various times between 2007 and 2009. Unfortunately for us I think other distributions came up with different patches.

The Qt binary distribution works find on Ubuntu based systems, it just requires package libnnss3, which will carry with it the nss subdiretory:

/usr/lib/x86_64-linux-gnu/libnss3.so /usr/lib/x86_64-linux-gnu/libnssutil3.so /usr/lib/x86_64-linux-gnu/libsmime3.so /usr/lib/x86_64-linux-gnu/libssl3.so /usr/lib/x86_64-linux-gnu/nss/libfreebl3.chk /usr/lib/x86_64-linux-gnu/nss/libfreebl3.so /usr/lib/x86_64-linux-gnu/nss/libnssckbi.so /usr/lib/x86_64-linux-gnu/nss/libnssdbm3.chk /usr/lib/x86_64-linux-gnu/nss/libnssdbm3.so /usr/lib/x86_64-linux-gnu/nss/libnsssysinit.so /usr/lib/x86_64-linux-gnu/nss/libsoftokn3.chk /usr/lib/x86_64-linux-gnu/nss/libsoftokn3.so /usr/share/doc/libnss3/changelog.Debian.gz /usr/share/doc/libnss3/copyright /usr/share/lintian/overrides/libnss3

probonopd commented 6 years ago

The issue seems to arise because of ubuntu libnss3 patch 85_security_load.patch

Interesting find!

DoctorJohn commented 6 years ago

I ran into the same issue running an AppImage built on Centos 7 on Ubuntu 18.04.

Using -exclude-libs="libnss3.so,libnssutil3.so" didn't work for me, I still couldn't run the AppImage on Ubuntu. However copying the .so and .chk files provided by the nss-softokn on Centos 7 manually into the AppImages /lib directory worked. I executed the following command in the AppImages folder to do so:

repoquery -l nss-softokn | grep '.so\|.chk' | xargs -i cp -R {} ./lib

The resulting AppImage runs on Centos 7, latest Arch Linux and Ubuntu 18.04 without complaining about missing libsoftokn3.so and whatnot.

probonopd commented 6 years ago

Does anyone know what a .chk file is?

tsteven4 commented 6 years ago

It is explained here: https://developer.mozilla.org/en-US/docs/Mozilla/Projects/NSS/NSS_Tech_Notes/nss_tech_note6

On Sat, Oct 13, 2018, 1:49 AM probonopd notifications@github.com wrote:

Does anyone know what a .chk file is?

— You are receiving this because you commented. Reply to this email directly, view it on GitHub https://github.com/probonopd/linuxdeployqt/issues/35#issuecomment-429520073, or mute the thread https://github.com/notifications/unsubscribe-auth/AM92MeqkAK6Lj7hqE24CYIAad4xNVtEgks5ukZsTgaJpZM4Kd2cK .

probonopd commented 6 years ago

PRs welcome!

DoctorJohn commented 6 years ago

What kind of patch could that be?

Looks like those .chk files are always called the same as the .so files they belong to. linuxdeployqt determines what .so files the program depends on using ldd right? So we could check whether there are matching .chk files next to them(?)

Any opinions on that?

(Sorry, posted the same thing earlier using a wrong github account)

probonopd commented 6 years ago

Yes, exactly as you describe @DoctorJohn

probonopd commented 5 years ago

libsoftokn3.so is seemingly still a pain:

me@host:~$ Downloads/REDasm_x86_64_20181231.AppImage Downloads/AppImageUpdate-x86_64.AppImage 
QBuffer::setData: Buffer is open
[9708:9734:0102/034434.903619:ERROR:nss_util.cc(712)] Error initializing NSS with a persistent database (sql:/home/me/.pki/nssdb): libsoftokn3.so: cannot open shared object file: No such file or directory
[9708:9734:0102/034434.903712:ERROR:nss_util.cc(201)] Error initializing NSS without a persistent database: NSS error code: -5925
[9708:9734:0102/034434.903732:FATAL:nss_util.cc(203)] nss_error=-5925, os_error=0
#0 0x7f35b3c0f5de <unknown>
#1 0x7f35b3c21d1e <unknown>
....
shoogle commented 4 years ago

For MuseScore we are bundling all the files that are part of the libnss3 package, namely:

/usr/lib/x86_64-linux-gnu/libnss3.so
/usr/lib/x86_64-linux-gnu/libnssutil3.so
/usr/lib/x86_64-linux-gnu/libsmime3.so
/usr/lib/x86_64-linux-gnu/libssl3.so
/usr/lib/x86_64-linux-gnu/nss/libfreebl3.chk
/usr/lib/x86_64-linux-gnu/nss/libfreebl3.so
/usr/lib/x86_64-linux-gnu/nss/libnssckbi.so
/usr/lib/x86_64-linux-gnu/nss/libnssdbm3.chk
/usr/lib/x86_64-linux-gnu/nss/libnssdbm3.so
/usr/lib/x86_64-linux-gnu/nss/libnsssysinit.so
/usr/lib/x86_64-linux-gnu/nss/libsoftokn3.chk
/usr/lib/x86_64-linux-gnu/nss/libsoftokn3.so

However, we don't load them by default. Instead we put them in a separate directory within the AppImage that only gets added to ${LD_LIBRARY_PATH} at runtime if libnss3.so is not found on the system.

andrewpriddis commented 4 years ago

libsoftokn3.so is seemingly still a pain:

me@host:~$ Downloads/REDasm_x86_64_20181231.AppImage Downloads/AppImageUpdate-x86_64.AppImage 
QBuffer::setData: Buffer is open
[9708:9734:0102/034434.903619:ERROR:nss_util.cc(712)] Error initializing NSS with a persistent database (sql:/home/me/.pki/nssdb): libsoftokn3.so: cannot open shared object file: No such file or directory
[9708:9734:0102/034434.903712:ERROR:nss_util.cc(201)] Error initializing NSS without a persistent database: NSS error code: -5925
[9708:9734:0102/034434.903732:FATAL:nss_util.cc(203)] nss_error=-5925, os_error=0
#0 0x7f35b3c0f5de <unknown>
#1 0x7f35b3c21d1e <unknown>
....

I'm seeing this same problem @probonopd mentioned on Jan 1. I don't know if this matters, but if I build my Qt project it runs properly. When I guild the AppImage, I see the error above. The interesting part is that if I go try to run the executable that I previously ran from the standard build it no longer works and gives the same error.

martinrotter commented 4 years ago

So guys, is there any "recommended" (dirty?) solution to get things working?

chapati commented 3 years ago

For MuseScore we are bundling all the files that are part of the libnss3 package, namely:

/usr/lib/x86_64-linux-gnu/libnss3.so
/usr/lib/x86_64-linux-gnu/libnssutil3.so
/usr/lib/x86_64-linux-gnu/libsmime3.so
/usr/lib/x86_64-linux-gnu/libssl3.so
/usr/lib/x86_64-linux-gnu/nss/libfreebl3.chk
/usr/lib/x86_64-linux-gnu/nss/libfreebl3.so
/usr/lib/x86_64-linux-gnu/nss/libnssckbi.so
/usr/lib/x86_64-linux-gnu/nss/libnssdbm3.chk
/usr/lib/x86_64-linux-gnu/nss/libnssdbm3.so
/usr/lib/x86_64-linux-gnu/nss/libnsssysinit.so
/usr/lib/x86_64-linux-gnu/nss/libsoftokn3.chk
/usr/lib/x86_64-linux-gnu/nss/libsoftokn3.so

However, we don't load them by default. Instead we put them in a separate directory within the AppImage that only gets added to ${LD_LIBRARY_PATH} at runtime if libnss3.so is not found on the system.

We've run into the same issue with libsoftokn3.so on Ubuntu 18 & 20 LTS while building on Ubuntu 16 LTS and went with a temporary exclude libs fix. @probonopd would you please add the workaround proposed by @shoogle above to the linuxdeployqt. May be it would be even better to add some general mechanism to define some list of libraries that would be loaded from inside appimage only if they are not present on a target system. Thanks.

chapati commented 3 years ago

So guys, is there any "recommended" (dirty?) solution to get things working?

There are two fixes that work at the moment:

1) Short and dirty and not for all systems (but seems to work on majority) https://github.com/probonopd/linuxdeployqt/issues/35#issuecomment-382994446 2) Long and better but significantly more painful to implement https://github.com/probonopd/linuxdeployqt/issues/35#issuecomment-574368963

paoletto commented 1 year ago

stumbled upon this one when building on 22.04 (because the appimage generated on 18.04 does not run on 22.04 sadly). So even on the same 22.04 system, when running the app from the appimage triggers this one :(