Skip to content

Instantly share code, notes, and snippets.

@Bargamut
Last active May 11, 2024 02:52
Show Gist options
  • Save Bargamut/e950f0fdbaf0ceb08a5ac766891ef9a4 to your computer and use it in GitHub Desktop.
Save Bargamut/e950f0fdbaf0ceb08a5ac766891ef9a4 to your computer and use it in GitHub Desktop.
My troubleshoots on the way of Electron startup via WSL

Bug with start

INSTALL Electron ONLY ON WINDOWS in case of work via Windows Subsystem for Linux (WSL). It has troubles with starting if you install it on Linux side.

Install tech dependencies

On Ubuntu under WSL you have to install some dependencies:

sudo apt update
sudo apt install \
    libnss3 \
    libnss3-dev \
    libatk1.0-0 \
    libatk-bridge2.0-0 \
    libcups2 \
    libdrm2 \
    libgtk-3-0 \
    libgtk-3-dev \
    libgbm1 \
    libasound2 \
    libgdk-pixbuf2.0-dev \
    libxss-dev \
    libgconf-2-4

Check DBus running status

Also you might see this error:

ERROR:bus.cc(407) Failed to connect to the bus: Failed to connect to socket /run/dbus/system_bus_socket: No such file or directory

For my case, it was caused by the fact that the service was not started. sudo service dbus start

Organize your DBus

"Failed to connect to the bus: Failed to connect to socket" "Failed to connect to the bus: Could not parse server address: Unknown address type (examples of valid types are "tcp" and on UNIX "unix")" "/node_modules/electron/dist/electron exited with signal SIGTRAP" (one of reasons)

export DISPLAY=$(ip route list default | awk '{print $3}'):0
export LIBGL_ALWAYS_INDIRECT=1
export LIBGL_ALWAYS_SOFTWARE=true

USER_ID=$(id -u)
USER_NAME=$(id -un)
USER_GROUP=$(id -gn)

XDG_RUNTIME_DIR=/run/user/$USER_ID
DBUS_SESSION_BUS_ADDRESS=unix:path=$XDG_RUNTIME_DIR/bus

#echo "Check if $XDG_RUNTIME_DIR exists"

#if [ -d $XDG_RUNTIME_DIR ]
#then
  echo "Create XDG runtime directory"

  sudo mkdir -p $XDG_RUNTIME_DIR

  echo "Set $USER_NAME:$USER_GROUP as owner"

  sudo chmod 700 $XDG_RUNTIME_DIR
  sudo chown $USER_NAME:$USER_GROUP $XDG_RUNTIME_DIR
#fi

echo "Specify dbus daemon for address $DBUS_SESSION_BUS_ADDRESS"

dbus-daemon --session --address=$DBUS_SESSION_BUS_ADDRESS --nofork --nopidfile --syslog-only &

Also see this guide about Electron on WSL2:

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment