mastodon / documentation

Mastodon documentation
https://docs.joinmastodon.org
GNU Free Documentation License v1.3
1.71k stars 975 forks source link

Vagrant instructions don't work for Apple silicon M1/M2 machines #1097

Open nileshtrivedi opened 1 year ago

nileshtrivedi commented 1 year ago

Docs in question: https://docs.joinmastodon.org/dev/setup/

Vagrant needs a "provider" for managing the virtual machine with commands like vagrant up and vagrant ssh. The Mastodon docs make no mention of which provider to use with Vagrant. Apple M1/M2 machines do not support VirtualBox or VMWare.

There's a virtualization app for Apple M1 called UTM that uses QEMU under the hood. I found an unofficial QEMU provider for Vagrant and installed it with brew install qemu and vagrant plugin install vagrant-qemu.

However, Mastodon's Vagrantfile requires the box image "ubuntu/bionic64" which only supports virtualbox (libvert) as the provider. Which is why this is my experience with using Mastodon's Vagrant setup on Apple M1 machine:

> vagrant up                                 
Bringing machine 'default' up with 'qemu' provider...
==> default: Box 'ubuntu/bionic64' could not be found. Attempting to find and install...
    default: Box Provider: libvirt
    default: Box Version: >= 0
==> default: Loading metadata for box 'ubuntu/bionic64'
    default: URL: https://vagrantcloud.com/ubuntu/bionic64
The box you're attempting to add doesn't support the provider
you requested. Please find an alternate box or use an alternate
provider. Double-check your requested provider to verify you didn't
simply misspell it.

If you're adding a box from HashiCorp's Vagrant Cloud, make sure the box is
released.

Name: ubuntu/bionic64
Address: https://vagrantcloud.com/ubuntu/bionic64
Requested provider: ["libvirt"]

This is even after I added the following section in the Vagrantfile as suggested by vagrant-qemu README:

  config.vm.provider "qemu" do |qe|
    qe.machine = "virt,accel=hvf,highmem=off"
    qe.cpu = "cortex-a72"
  end
nileshtrivedi commented 1 year ago

One potential solution could be to have vagrant-qemu somehow emulate the libvirt provider. vagrant-qemu wiki seems to only document the creation of a libvirt box. I have asked them if emulation of libvirt for pre-existing boxes is somehow possible.

A second solution might be possible if Vagrant were to provide an option to force a box to work with another provider. I am not aware of a way to do this.

But this issue is for Mastodon switching to a box that does work with qemu provider and therefore, Apple M1 machines without new features like the above two.

nileshtrivedi commented 1 year ago

I discovered that VirtualBox now has a Developer Preview build for Apple M1/M2 hosts. However, this doesn't actually work for me as the machine created by vagrant with ubuntu/bionic64 box gets aborted. Even if that were to be fixed, the performance will likely be terrible. These comments are explanatory:

Treat the M1 build as a very very early technical preview please, the Beta label is completely misleading and will be changed (this comes from the automated build system and aligns with the rest of the builds). There will be no official support for M1 with 7.0, not even for ARM virtualization, let alone x86 emulation on ARM.

And,

In a way the ARM64 package "slipped out", and it's not expected to work reliably. The implementation isn't complete yet (which is what you saw), and in top of that the performance is known to be extremely low. It isn't anywhere near production ready, we know. This will not change for VirtualBox 7, and the "Technology Preview" marker will stay for the foreseeable future, indicating that it won't be supported at all.

At best you'll get some really old 32-bit Linux to run to some degree, such as DSL 4.4.10. No chance even with Ubuntu 16.04 i386.

So, we do need a solution for running the Mastodon vagrant box on Apple M1/M2 machines.