Wkhtmltopdf segnmenation fault

The problem itself is JavaScript not rendering / segmentation fault on FreeBSD with wkhtmltopdf). To fix it, please follow the steps below.

This can only be solved by using the Linux version (CentOS).

1. Enable Linux mode: `sudo /etc/rc.d/linux enable`

2. Start Linux mode: `sudo /etc/rc.d/linux start`

3. Install CentOS basic libraries: `sudo pkg install linux_base-c7` and verify mount.

sudo linux_mount linprocfs "/compat/linux/proc" -o nocover
sudo linux_mount linsysfs "/compat/linux/sys" -o nocover
sudo linux_mount devfs "/compat/linux/dev" -o nocover
sudo linux_mount fdescfs "/compat/linux/dev/fd" -o nocover,linrdlnk
sudo linux_mount tmpfs "/compat/linux/dev/shm" -o nocover,mode=1777
sudo mount

Note: Do not use /etc/fstab, Linux file systems will automatically be mounted on boot.

4. Extract the missing libraries from the file linux_libraries_update.tgz

`sudo tar -x --directory=/compat/linux -f linux_libraries_update.tgz`

This is for FreeBSD AMD64, alternatively just download all libraries to `/compat/linux/lib64`

5. Extract the CentOS 8 version from https://rubygems.org/gems/wkhtmltopdf-binary/

Normally, this gem is already installed.

`sudo gzip -dk /usr/local/lib/ruby/gems/2.7/gems/wkhtmltopdf-binary-0.12.6.6/bin/wkhtmltopdf_centos_8_amd64.gz`

`sudo mv /usr/local/lib/ruby/gems/2.7/gems/wkhtmltopdf-binary-0.12.6.6/bin/wkhtmltopdf_centos_8_amd64 /usr/local/lib/ruby/gems/2.7/gems/wkhtmltopdf-binary-0.12.6.6/bin/wkhtmltopdf_unknown`

`sudo chmod 755 /usr/local/lib/ruby/gems/2.7/gems/wkhtmltopdf-binary-0.12.6.6/bin/wkhtmltopdf_unknown`

6. Change Redmine configuration to use the new binary:

`config/configuration.yml` * `wkhtmltopdf_exe_path: '/usr/local/lib/ruby/gems/2.7/gems/wkhtmltopdf-binary-0.12.6.6/bin/wkhtmltopdf'`

7. Change wkhtmltopdf executable script to use the correct library path:

`/usr/local/lib/ruby/gems/2.7/gems/wkhtmltopdf-binary-0.12.6.6/bin/wkhtmltopdf`

Add:

`ENV['LD_LIBRARY_PATH'] = '/compat/linux/usr/lib64'` before `exec *$*.unshift(binary)`

If the Ruby interpreter path is not found, you can link it using:

`sudo ln -s /usr/local/bin/ruby /usr/bin/ruby`

Was this article helpful? Yes  No
364 from 415 found this helpful