PhantomJS launcher fails on latest Pop!_OS, cannot find shared library libproviders.so
Asked Answered
C

3

9

We have a system (Power TAC) that has been building successfully for several years on multiple versions of Linux, Windows, and MacOS. Under Pop!_OS 22.04 (Ubuntu 22.04 with a slightly different appearance), the maven build fails with the message

[INFO] 03 06 2022 19:42:21.934:INFO [launcher]: Starting browser PhantomJS [INFO] 03 06 2022 19:42:22.005:ERROR [phantomjs.launcher]: Auto configuration failed [INFO] 140172241258432:error:25066067:DSO support routines:DLFCN_LOAD:could not load the shared library:dso_dlfcn.c:185:filename(libproviders.so): libproviders.so: cannot open shared object file: No such file or directory

OpenSSL is installed and works. Not sure what to try next. Any ideas welcome.

Clymer answered 4/6, 2022 at 1:31 Comment(0)
C
10

Ubuntu 22.04 uses the new OpenSSL version 3.0.2 instead of the older OpenSSL version 1.1.1 . These OpenSSL versions are not fully compatible, so this is why you see this error when PhantomJS tries to auto configure the SSL/TLS settings.

If you don't need OpenSSL for your PhantomJS application you can disable SSL by setting the following environmental variable, before you run your application:

export OPENSSL_CONF=/dev/null

# or you can set it when you run the application

OPENSSL_CONF=/dev/null ./yourapp

Otherwise you can uses containerization tools (such as Docker) to pack an older OpenSSL version along your application.

Corn answered 19/6, 2022 at 17:57 Comment(2)
I would think this will impact the functionality of phantomSands
If you are talking about disabling openssl, then yes it will mean that phantomJS will be unable to use HTTPS. But this can be a non-issue depending on what you are using PhantomJS for. Also, to my knowledge, it seems that PhantomJS is not actively maintained anymore, so if you are expecting high security from it then you will be surprised.Corn
W
2

There is a workaround for the lastest PhantomJS version. You can install PhantomJS on Ubuntu 22.04 LTS, see https://gist.github.com/julionc/7476620.

I used another version of PhantomJS, https://phantomjs.org/download.html (phantomjs-2.1.1-linux-x86_64.tar.bz2) but you can use the version of the thread.

To use the PhantomJS on Ubuntu 22.04 you have to install an OpenSSL Version 1.x in a different directory. Attention, DO NOT overwrite the OpenSSL of the system! This will mess up your system. Remark: If you use the OpenSSL Version 1.x and the old PhantomJS (2016!) you should run the command as an unprivileged user.

Install PhantomJS as mentioned. If you run PhantomJS you get the following error:

Auto configuration failed
140398212290496:error:25066067:DSO support routines:DLFCN_LOAD:could not load the shared library:dso_dlfcn.c:185:filename(libproviders.so): libproviders.so: cannot open shared object file: No such file or directory

Build your own OpenSSL in a subdirectory and connect phantomjs:

# All commands as unprivileged user, download the latest OpenSSL Version 1.x
cd $HOME
mkdir src
mkdir share
cd src
wget https://github.com/openssl/openssl/releases/download/OpenSSL_1_1_1w/openssl-1.1.1w.tar.gz
# Check SHA256 Sum
sha256sum openssl-1.1.1w.tar.gz # MUST MATCH!
tar xzf openssl-1.1.1w.tar.gz 
cd openssl-1.1.1w/

You must know your os/compiler type to compile the openssl source. The possible os/compilers are in the documentation https://wiki.openssl.org/index.php/Compilation_and_Installation#Supported_Platforms or call ./Configure and read the output.

# My system is linux-x86_64
./Configure --prefix=$HOME/share/openssl-1.1.1 --openssldir=$HOME/share/openssl-1.1.1 linux-x86_64
make
make install

Now everything is in place, you can use the openssl version 1.x with this command:

# run as unprivileged user!
$ OPENSSL_CONF=$HOME/share/openssl-1.1.1 phantomjs --version
2.1.1
$ OPENSSL_CONF=$HOME/share/openssl-1.1.1 phantomjs --ignore-ssl-errors=true rasterize.js https://stackoverflow.com
Wont answered 13/9, 2023 at 19:41 Comment(0)
D
0

THANK you so much for the detailed information as well as the exact commands to follow. This was very useful in particular because I am using an RStudio Docker container without root access and thus the first option would not have worked.

I think that the very last set of commands in your answer could be updated in this way:

  1. The definition of the variable should only contain the PATH to the openssl-1.1.1 directory as such:
OPENSSL_CONF=$HOME/share/openssl-1.1.1
  1. For the test with rasterize.js I had to actually write it as $HOME/bin/rasterize.js for it to work.

  2. Finally, I had to pass this information within a Quarto .qmd file for processing and I found the relevant info on page Accessing environment variables set in R session from shell SO I added a "chunk" to pass the value of the variable within:

library(webshot)
Sys.setenv(OPENSSL_CONF='$HOME/share/openssl-1.1.1')
system("echo $OPENSSL_CONF")

With this in place it now worked if the YAML at the top of the file contained the following for PDF output:

format:
  pdf:
    prefer-html: false

Thank you again! JYS

Disaccustom answered 30/8 at 16:40 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.