Using Bottles to Run Windows-Based Electron Apps on Linux

A screenshot of a Windows-Based Electron application running on Linux

I recently got a hold of a piece of software that I had been eagerly awaiting the arrival of for some time. It came in the mail via USB flash drive and proudly advertised that it would only work on Windows and Mac OSX. Knowing a thing or two about computers, I (perhaps, over-) confidently ignored these instructions and set out to make it work on Linux.

What Was It?

About a week ago, I purchased a digital archive of a long-running permaculture and homesteading magazine called Mother Earth News, which is a favorite of mine. The magazine has been in print since 1970 and was around during a lot of the Back-to-the-land movement at that time. They still publish to this day and are a solid source for DIY farming, baking, market-gardening, canning, bee keeping, and self sufficiency, among other things.

It's a great piece of knowledge to have on hand in case you want to do any off-the-grid living, gardening, or anything that we would now classify as "solarpunk".

I purchased a USB stick containing all of their articles since the 70's through to 2024, and at just about $30, it was a steal. The only catch was that I had some previous experience with their archive software, and suspected it probably wouldn't be smooth sailing right out of the box. 

How The Old Archive Was Built

In older iterations of this archive (circa 2015), the experience was built around a simple index.html file that had some local JavaScript attached to it. The JavaScript would load a bunch of static files from the USB drive including images, markup, and some search functionality to give the appearance of a native application that just ran in you web browser.

Neat! Or, at least it was until CORS became a thing. Modern web browsers refuse to load the old archives because they pose a security risk. So, the old archives just flat out won't work on most recent computers

The new archive USB packages the exact same static website as an Electron application for Mac OSX and Windows, meaning the security issues get properly resolved, and the web resources are loaded as native resources.

Neat! Or, it would be if Mother Earth news made a Linux build (or at least the source code), which brings me to WINE and Bottles.

What is WINE and Bottles?

WINE is a piece of software the creates a working Windows software environment. In short, it enables you to tun Windows applications on non-windows computers without hardware emulation.

Bottles is a Linux application that makes it super easy to use WINE and encapsulate different software environments into different so-called "bottles".

The goal here is to use the Windows version of the application that came with my USB stick and make that run on a Linux machine without having to set up a Windows partition or even an emulator.

Simple Bottles Configuration & Installation for Electron Apps

I've used Bottles a few times in the past to package and run Windows applications on Linux, and the overall approach is pretty simple.

First of all, it's worth noting that I am using the Flatpak build of bottles because I find that it is behaves just a little more consistently than a native build. The only real challenge here is, later on, navigating through the Flatpak file tree to find certain directories, but otherwise it's not a big deal.

First, create a new "Application" bottle titled whatever you want it to be titled.

A screenshot of the bottles program showing a dialogue that lets you create a new bottle.

Wait for the install to finish, then click into the bottle to configure it.

A screenshot of the bottles program showing a newly created bottle called "Mother Earth News Archive"

Then click the "Add Shortcuts" button This should open a file picker window pointed at the location of that bottle's C drive. 

Open that location in a separate file browser window.

Copy and paste the contents of your Electron application somewhere into that C drive. I just dumped mine onto the desktop. You might want to put yours in a nice file tree somewhere else in that system if you plan on using this Bottle for something else.

A file browser with two tabs. One showing the files in the USB archive, and the other showing the copy of those same files in the Desktop folder of a BottleA file picker window showing a list of files and executables that bottles could launch. The ones I want are located on the desktop.

Back in the Bottles file picker window, navigate the file picker to the the Launch.exe file in the C drive (or whatever the primary entry point executable is) and click "Add".

Test the environment by running the Launch.exe file in Bottles. You can just press the triangular "Play" button next to your executable. If everything is working properly, your program should just launch, no muss, no fuss!

A window showing the Mother Earth News Archive Electron Application running in WINE using Bottles

However, if there is a problem, you can tend to get an idea of what went wrong by launching the executable with the terminal and reading the log output. Usually, the culprit is just downloading a couple of pieces of software dependencies, but I suspect most Electron apps aren't going to need that extra hand holding.

A screenshot of the bottles application showing that you can run a program in the terminal, thus getting valueable logging messages if the bottles doesn't work

I've also found it convenient to have the application generate a Desktop Entry for me, but do be aware that the desktop entry file will be located in ~/.var/app/com.usebottles.bottles/data/applications/ (if you installed Bottles as a user and not with sudo). All this means is that, in order to use this desktop entry, you should copy it to ~/.local/share/applications/ first, and then it should show up in your launcher of choice.

And that's all there is to it! So far, I've noticed the the application is just a tad slow on the first launch, but seems to be faster afterwards. I'm not sure if this is an issue with Electron, WINE, Bottles, or something else, but it works well enough for my purposes that I won't trouble myself with trying to optimize it too much.

Comments

Restricted HTML

  • Allowed HTML tags: <a href hreflang> <em> <strong> <cite> <blockquote cite> <code> <ul type> <ol start type> <li> <dl> <dt> <dd> <h2 id> <h3 id> <h4 id> <h5 id> <h6 id>
  • Lines and paragraphs break automatically.
  • Web page addresses and email addresses turn into links automatically.

About Me

I am a writer-turned-web-developer-turned-writer-again. My blog focuses on experimental literature, constrained writing prompts, and original works of poetry. I am also currently writing a mystery novel. Join me here to talk about all things fringe writing, nontraditional novels, and more.