akauppi / mp

WSL-like development sandboxes but on Mac using Multipass
1 stars 0 forks source link
multipass

mp

Scripts for setting up Multipass virtual machines, in the way of WSL, but on macOS.

Why?

World is a risky place. Sandboxing allows you to separate business account (emails etc.) from developer account (that pulls in stuff from third party sources on the Internet), without disturbing the workflow, too much.

One can use containers for development, but Docker Desktop feels too big a tool for daily use, for this author.

Discipline

Sandboxing of course needs discipline. The mp approach is done so that:

  1. Tooling is separate from development repos

    This is important so that your repos are not cluttered by toolchain choices. A repo would work "just fine" with native tooling, if someone so wishes.

  2. We want to support remote IDE's

    However, this does require a beefier machine to run (more cores; more memory). You might opt for partially VM-based workflows, but it's still better than not starting the sandbox transition.

Alternatives

Fully cloud-based sandbox-as-a-service comes to mind.

This can be ideal for you, but this author prefers to have the option of locally hosted, offline-capable development.

It's possible, by -say- 2026, that such remote development platforms become the norm. They certainly have many things going for them, in the same way as multiplayer games have.

Sandboxes available

Requirements

The system is intended to work on all macOS, Linux and Windows hosts, but is only tested on macOS. If you find issues, please create an Issue!

Note: For Windows, Pro versions are recommended since only they provide Hyper-V (native) virtualization.

Usage

$ rust/prep.sh
[...]

It works the same for web/prep.sh.

Multipass IP (rust): 192.168.64.74

cargo 1.80.1 (376290515 2024-07-16)
rustc 1.80.1 (3f5fd8dd4 2024-08-06)
usbip (usbip-utils 2.0)

To add a project folder to be shared between the host (macOS) and the Linux side:

$ multipass mount -type native $(pwd) rust:/home/ubuntu/SOME

$ multipass start rust

Then:

$ multipass shell rust

You are now in an Ubuntu sandbox.

Hints

Separate color for the VM terminal

Change your Multipass terminal's look by (right click) > Show Inspector. Different coloring helps tremendously!

Accessing USB devices

Multipass does not provide USB pass-through. However, you can reach USB devices using e.g. usbipd-win.

tbd. If needed, a separate docs/ file about this.

WARNING ON MULTIPASS 1.14!!

It some some issues with mounts. Until those are resolved, you should:

A bit harsh, but.. since you can easily recreate the VM's from nothing (with mp), shouldn't be worth risking the stability.


IF you get such an error:

$ mp stop --force rust-emb
[2024-08-30T12:30:41.371] [error] [rust-emb] process error occurred Crashed program: qemu-system-x86_64; error: Process crashed
[2024-08-30T12:30:41.373] [error] [rust-emb] error: program: qemu-system-x86_64; error: Process crashed

...restart the Multipass service, and retry the stop (no host reboot is needed):

$ sudo launchctl unload /Library/LaunchDaemons/com.canonical.multipassd.plist
$ sudo launchctl load /Library/LaunchDaemons/com.canonical.multipassd.plist
$ mp stop rust-emb