Getting Tauri working in WSL
5 reactions 2022-10-05
Update: Tauri has good guidelines for working with homebrew and a clear set of prerequisites for linux. Not sure if I missed these before or they were added later, but those docs basically describe how to avoid the installation problems I ran into.
- Don’t use homebrew; use your distro’s package manager instead (I used apt on ubuntu 20.04).
- Install wslg according to instructions.
- Install latest GPU drivers.
- DON’T install a 3rd-party X server like VcXsrv.
- DON’T install xfce4.
export DISPLAY=:0to your shell file, e.g.
I’ve been chipping away at a personal task manager clone (who isn’t these days?), and wanted to begin packaging the app for desktop. I recently heard about tauri.app, which sounds like a very promising electron alternative. I love their philosophy of security and local-first apps; this has been something on my mind for quite a while. I appreciate cloud connectivity as an option, but for something like a simple task manager, why do you need to talk to your servers?! Let me choose that please.
Tauri is built in Rust, and because it’s a desktop app, it obviously has some visual components that run outside of the cli. I do a lot of my personal development on my windows machine in WSL. It’s fantastic overall, but how do I run desktop apps from it? There’s no way I wanted to set up Tauri in windows and pollute my environment again.
It turns out that wslg has been around for a bit and provides a way to run linux desktop apps as companion apps to the rest of your windows app. That’s so cool. Through a process of trial and error, I discovered that getting wslg going was pretty easy, but getting tauri from within wsl was not. Essentially, I found that using homebrew to install wslg packages in my wsl distro (Ubuntu 20.04) caused a lot of issues. Resorting to the native package manager to install the same dependencies worked much better.
A number of
*-dev packages were required to be present to boot tauri properly. I noticed a number of issues with
pkg-config and missing packages. I used the ubuntu 20.04 package repository search whenever I saw an error message about a missing package to determine which packages to install.
The full install line was this:
Finally, I need to add
export DISPLAY=:0 to my
After running through the various required steps and navigating around some speedbumps, I got it working! Tauri has a very easy-to-use init script. Watching that desktop GUI come up the first time after running
npm run tauri dev is very satisfying. I’m looking forward to exploring its APIs.
For more info on potential issues with tauri and wslg, have a look at this: https://github.com/tauri-apps/tauri/issues/380