Running a Linux VM on a Mac?

Can anybody here recommend a good way to get a basic Linux VM running on my (Apple Silicon) Mac?

I don’t want to mess with bootcamp or anything crazy like that. Ideally I don’t want to have to install some massive distribution I only need 1% of.

I pretty much need vi and a recent version of clang++ (or g++) and bison. Well, and a way to either communicate with the parent OS, or the ability to connect to my GitHub.

The only parts of my code that are platform-dependent are some memory leak tracking code in the compiler (already marked up with #ifdef APPLE and the terminal handling code in the interpreter (even that is mostly VT-100 escape sequences).

Thanks,

-Dave

Rather than running a full VM, you might want to try a Docker container first:

https://docs.docker.com/desktop/setup/install/mac-install/

1 Like

With the caveat that I haven’t used it myself yet, Lima is supposed to make this very easy.

1 Like

UTM is good for this as well. It is a wrapper for qemu with a management interface. For best performance you should install the ARM version of a recent Linux distro.

Unclear why you want Linux at all since MacOS is itself BSD Unix. All the tools you need are already there:

$ which bison
/usr/bin/bison
$ which clang++
/usr/bin/clang++
$ which vi
/usr/bin/vi
$ which g++
/usr/bin/g++

Anything else you need can be added via homebrew.

1 Like

Because I want to make sure my code builds on Linux.

3 Likes

Originally. But it carries an ancient shell (zsh?) and the Python it comes with has very creaky knees.

To test Mac builds of Dialog, we currently use Github’s automated build tools. It’s free for open-source projects and means that, no matter which platforms we’re developing on, we can run all the test cases on both Mac and Linux machines before accepting a pull request. (Not Windows currently because its terminal equivalent is so different, so translating the testing pipelines is agony.)

The same system compiles the binaries for each platform when we release. I’d never used this system before Dialog, but it’s so convenient, I’ve set it up for the Å-machine project as well.

4 Likes

VMware Fusion is now free. There’s also VirtualBox, but it’s slower. Either way, I’d recommend something like Fedora for the install — it’s pretty easy to install. Normally I’d recommend Debian, but Debian’s currently a pain to install in VMware on ARM. Ubuntu is increasingly weird as they move to using Snap for everything.

Make sure you download the ARM64 / aarch64 install image for whatever Linux you pick.

2 Likes