# Getting Tauri working in WSL

<table><tbody><tr><td colspan="1" rowspan="1"><p><strong>Update:</strong> Tauri has good guidelines for <a target="_blank" rel="nofollow" class="rgh-seen--5229989788" href="https://tauri.app/v1/guides/faq#build-conflict-with-homebrew-on-linux" style="pointer-events: none">working with homebrew</a> and a clear set of <a target="_blank" rel="nofollow" class="rgh-seen--5229989788" href="https://tauri.app/v1/guides/getting-started/prerequisites#setting-up-linux" style="pointer-events: none">prerequisites for linux</a>. 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.</p></td></tr></tbody></table>

> TL;DR:
> 
> * 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.
>     
> * Add `export DISPLAY=:0` to your shell file, e.g. `~/.zshrc`.
>     

I've been chipping away at a [personal task manager clone](https://github.com/martypenner/tasks-app) (who isn't these days?), and wanted to begin packaging the app for desktop. I recently heard about [tauri.app](https://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](https://learn.microsoft.com/en-us/windows/wsl/install). 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](https://github.com/microsoft/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](https://packages.ubuntu.com/) whenever I saw an error message about a missing package to determine which packages to install.

The full install line was this:

```dockerfile
sudo apt install pkg-config \
  libdbus-1-dev \
  libgtk-3-dev \
  libsoup2.4-dev \
  libjavascriptcoregtk-4.0-dev \
  libwebkit2gtk-4.0-dev
```

Finally, I need to add `export DISPLAY=:0` to my `~/.zshrc` file.

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: [tauri-apps/tauri#380](https://github.com/tauri-apps/tauri/issues/380)

[![tauri](https://user-images.githubusercontent.com/1819798/194204056-fd6048e4-db00-49af-9d64-27a90db7f3c9.png align="left")](https://user-images.githubusercontent.com/1819798/194204056-fd6048e4-db00-49af-9d64-27a90db7f3c9.png)
