🍷 Wine Bonsai
These are my thoughts and experience so far using Wine to run Bonsai on Linux instead of Mono. I talk about why I think this approach is preferable over the traditional Mono setup, and how you can try this out for yourself.
💻 What is Bonsai?
Bonsai-Rx is a powerful, open-source, and cross-platform framework for building and running real-time applications for data acquisition and experimentation. It is designed for rapid prototyping and ease-of-use through it's visual programming interface, making it ideal for a wide range of applications.
As a big proponent of open-source, I always felt a bit disappointed with the fact that Bonsai-Rx, written in C#/.NET, was not cross-platform. Of course, when Bonsai on Mono became available, this was a huge step forward for Linux users, but still left many things to be desired.
🤔 Why Not Just Use Mono?
While Bonsai has historically supported running on Linux via Mono, there are growing reasons to explore Wine as an alternative. But first, some background.
Mono vs. Wine
- Mono was built to let Linux systems run Windows applications based on the old .NET Framework.
- Over time, .NET evolved into .NET Core and later the .NET SDK, both of which are cross-platform.
- As a result, Mono primarily supports legacy .NET apps and has seen declining support and development.
- The project was eventually handed over to the Wine community.
Meanwhile, Wine is a compatibility layer designed to run Windows applications directly on Linux. It's been instrumental in projects like Proton (used in Valve's Steam Deck), and remains actively developed and supported.
💡 Why This Matters for Bonsai
Bonsai runs surprisingly well with Mono, but it's not without issues — especially as Linux OSs continue to evolve. Here is a list of a few issues I've compiled down below:
- GitHub issue on assembly loading
- Conditional behavior in source: PackageConfigurationUpdater.cs#L40
- Editor/styling logic: EditorForm.cs#L132 TableLayoutPanel.cs#L10
- Mouse and keyboard shortcuts — like dragging with
Shift
to remove connections — may stop working in Mono. - Installing packages with external dependencies (e.g.
Bonsai.Vision
requiresOpenCV
dlls,Bonsai.Shaders
requiresOpenGL
dlls, etc) requires many extra steps
✅ Wine is a Better Option
In theory, Wine is better suited for running Bonsai as it is designed for compatability with the latest applications built on Windows to run on Linux OSs. Thus, running Wine could provide the following benefits:
- No need for developers to write Mono-specific logic into Bonsai packages.
- More consistent keyboard/mouse behavior.
- Better support for native DLLs, like those in OpenCV.
- Active development, especially from the gaming world.
- Works with minimal setup via
winetricks
.
I don't believe that all of these things will be easy to set up and use, but I do think it could provide a significant boost in usage for cross-platform users.
🔧 My Experience So Far
As I've been testing and experimenting with this method, I have come up with a setup guide to running Bonsai on Wine. At the time of writing, I am using Wine version 10.3.
Setup guide
- Build Wine from Source
Follow the official WineHQ Building Wine guide.
Be sure to install all required dependencies and optionally the 32-bit ones (needed for shared WoW64).
Patch TreeView
Edit dlls/comctl32/treeview.c
and comment out line 4515:
// assert(newSelect == NULL || TREEVIEW_ValidItem(infoPtr, newSelect));
- Build Shared WoW64
Follow the steps for Shared WoW64 to build both 64-bit and 32-bit versions of Wine.
- Update Your PATH
Update your system or terminal’s PATH to include the new Wine binaries:
export PATH=$PATH:/home/username/wine-dirs/wine64-build
Also include the path to tools/winegcc in your PATH.
- Install dependencies with Winetricks
You can use winetricks to install all of the dependencies needed to run Bonsai:
winetricks -q dotnet48 allfonts gdiplus
This installs the required .NET frameworks (both dotnet48 and dotnet40), as well as system fonts and gdiplus for visual improvements.
You can confirm that the changes have been made by running:
wine winecfg
You should see in the Libraries
tab that the installed dlls are set to "Native".
🎆 Results
The editor looks and feels so much better than before and looks nearly identical to Windows.
Keyboard shortcuts and editor features work out-of-the-box.
Packages like Bonsai.Vision
and Bonsai.Shaders
work immediately without any extra steps.
Using Wine v10.3 to run Bonsai v2.8.5.
⏱️ Final Thoughts and Future Outlook
While the steps to install are definitely a pain and could be improved, once it is working, it is a huge improvement to the existing method.
Having the keyboard and mouse functionality working reliably has been a huge boost to my productivity when building Bonsai workflows.
Certain features still need extra steps unfortunately, for example getting CUDA to work on Wine for GPU programming.
Needless to say, with Mono’s future uncertain and lack of feature support compared to Wine’s active development and overall improved compatibility, I won't be switching back to Mono anytime soon.