Tor browser won’t start
Posted: 2023-07-02 Filed under: desktop, network, system | Tags: browser, gdk_wayland_display_get_wl_compositor, libxul.so, shim.c, shim.so, tor, tor-browser, XPCOM, XPCOMGlueLoad Leave a commentOn CRUX 3.7, the Tor browser (version 12.5 at the moment) fails to start. It is not available as a port, so I just downloaded the Linux tarball from the official website, extracted it, and tried to run the program. Nothing. Therefore, I decided to find out what’s wrong and search for a fix.
I am not making a port, instead I put the program’s folder in /opt. Inside /opt/tor-browser/Browser/, there’s a binary called firefox.real. Starting it from the terminal returns the following:
XPCOMGlueLoad error for file /opt/tor-browser/Browser/libxul.so: /opt/tor-browser/Browser/libxul.so: undefined symbol: gdk_wayland_display_get_wl_compositor Couldn't load XPCOM.
So, I searched for the error and found a discussion about it in the Gentoo forum, which pointed me to this workaround at the project’s web-site.
Following the instructions, I created a file called shim.c, with these contents:
#include <stdlib.h>
void gdk_wayland_display_get_wl_compositor() { abort(); }
void gdk_wayland_device_get_wl_pointer() { abort(); }
void gdk_wayland_window_get_wl_surface() { abort(); }
void gdk_wayland_display_get_wl_display() { abort(); }
Then I built a shared object out of it:
cc -shared -o shim.so shim.c
This produces a shim.so library file, which I placed within the /opt/tor-browser/Browser/ folder. However, it needs to be pre-loaded upon Tor browser start from the start-tor-browser.desktop file. The problem is that this desktop file gets overwritten each time it’s started, which will reset the changes. I made a custom tor-browser.desktop file, containing:
[Desktop Entry] Type=Application Name=Tor Browser GenericName=Web Browser Comment=Tor Browser is +1 for privacy and −1 for mass surveillance Categories=Network;WebBrowser;Security; Exec=env LD_PRELOAD=/opt/tor-browser/Browser/shim.so sh -c '"/opt/tor-browser/Browser/start-tor-browser" --detach || ([ ! -x "/opt/tor-browser/Browser/start-tor-browser" ] && /opt/tor-browser/Browser/start-tor-browser --detach)' dummy %k X-TorBrowser-ExecShell=/opt/tor-browser/Browser/start-tor-browser --detach Icon=/opt/tor-browser/Browser/browser/chrome/icons/default/default128.png StartupWMClass=Tor Browser
Paths are adjusted to point to /opt. I place it in ~/.local/share/applications, so it appears in my menu. So far, things work.
For the record, I am not paranoid about surveillance, I just like to have the Tor Browser around.
