ardupilot_wiki icon indicating copy to clipboard operation
ardupilot_wiki copied to clipboard

Vagrant doesn't work on Apple Silicon Macs because ubuntu/jammy64 is not an Arm image

Open master0v opened this issue 1 year ago • 13 comments

I am following the instructions on this page: https://ardupilot.org/dev/docs/setting-up-sitl-using-vagrant.html

When I get to "vagrant up" step - it craps out due to the fact that Vagrant 2.4.1 doesn't support virtualbox Version 7.1.2 r164945 (Qt6.5.3). That can be fixed with the suggestion provided here: https://github.com/hashicorp/vagrant/issues/13501

Once that is working, however, the fundamental problem is that the VM that it is trying to pull is built for the Intel architecture. Here is the full error message:

MacBook-Pro ardupilot % vagrant up --provider=virtualbox   
Bringing machine 'jammy' up with 'virtualbox' provider...
==> jammy: Checking if box 'ubuntu/jammy64' version '20240912.0.0' is up to date...
==> jammy: Clearing any previously set forwarded ports...
==> jammy: Clearing any previously set network interfaces...
==> jammy: Preparing network interfaces based on configuration...
    jammy: Adapter 1: nat
==> jammy: Forwarding ports...
    jammy: 22 (guest) => 2222 (host) (adapter 1)
==> jammy: Running 'pre-boot' VM customizations...
==> jammy: Booting VM...
There was an error while executing `VBoxManage`, a CLI used by Vagrant
for controlling VirtualBox. The command and stderr is shown below.

Command: ["startvm", "8ef543d5-204a-4df4-830f-d075932bdcd3", "--type", "headless"]

Stderr: VBoxManage: error: The VM session was aborted
VBoxManage: error: Details: code NS_ERROR_FAILURE (0x80004005), component SessionMachine, interface ISession

The same issue happens when I try to run the VM from the UI:

Screenshot 2024-10-03 at 11 13 09

Would it be possible to support this? Thank you!

master0v avatar Oct 03 '24 09:10 master0v

From random googling, it may be possible by changing the machine from eg. ubuntu/jammy64 to perk/ubuntu-2204-arm64

https://portal.cloud.hashicorp.com/vagrant/discover/perk/ubuntu-2204-arm64

There may also be bento boxes to allow for it.

You might need to experiment a bit :-)

peterbarker avatar Oct 03 '24 11:10 peterbarker

Forgive me for the dumb question, but how do you change it?

Simply replacing 'ubuntu/jammy64' with 'perk/ubuntu-2204-arm64' in Vagrantfile didn't work:

MacBook-Pro ardupilot % vagrant up --provider=virtualbox
Bringing machine 'jammy' up with 'virtualbox' provider...
==> jammy: Box 'perk/ubuntu-2204-arm64' could not be found. Attempting to find and install...
    jammy: Box Provider: virtualbox
    jammy: Box Version: >= 0
==> jammy: Loading metadata for box 'perk/ubuntu-2204-arm64'
    jammy: URL: https://vagrantcloud.com/api/v2/vagrant/perk/ubuntu-2204-arm64
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: perk/ubuntu-2204-arm64
Address: https://vagrantcloud.com/api/v2/vagrant/perk/ubuntu-2204-arm64
Requested provider: virtualbox (arm64)

master0v avatar Oct 03 '24 15:10 master0v

Add the following to your Vagrantfile before running vagrant up:

ruby Vagrant.configure("2") do |config| config.vm.provider "virtualbox" do |vb| vb.customize ["modifyvm", :id, "--cpuidset", "00000001", "000306a9", "00100800", "7ffafbbf", "bfebfbff"] end end

Update vagrant bash:-
brew install vagrant

otherwise use this :- Vagrant.configure("2") do |config| config.vm.box = "bento/ubuntu-22.04-arm64" # Choose an ARM-compatible box end

and re initialize vagrant reload --provision

Knowledgelocater avatar Nov 13 '24 12:11 Knowledgelocater

I am finding that bento/ubuntu-22.04-arm64 is not compatible with Virtualbox as the provider. Has anyone else experienced differently?

EDIT: To clarify, I am working on an Apple Silicon host machine so need both arm64 architecture and Virtualbox provider.

jeromecovington avatar Dec 20 '24 22:12 jeromecovington

I have the same problem

xooooooooox avatar Dec 28 '24 18:12 xooooooooox

if you guys are having problem with this bento/ubuntu-22.04-arm64 then directly use bento/ubuntu-22.04 it is compatible. For use :- vagrant init bento/ubuntu-22.04 vagrant up --provider=virtualbox as this is compatible on x86_64 if not this also the use generic.

I hope this will be helpfull

Knowledgelocater avatar Dec 29 '24 03:12 Knowledgelocater

@Knowledgelocater I struggle with your suggestion - getting an error message:

There was an error while executing `VBoxManage`, a CLI used by Vagrant
for controlling VirtualBox. The command and stderr is shown below.

Command: ["startvm", "0cf4805c-24af-4a1b-a588-d9ae4362d160", "--type", "headless"]

Stderr: VBoxManage: error: The VM session was aborted
VBoxManage: error: Details: code NS_ERROR_FAILURE (0x80004005), component SessionMachine, interface ISession

I also tried it with other arm64 based boxes. Always the same result.

Any hints? Thanks very much!

mknet avatar Jan 08 '25 16:01 mknet

@mknet if there is still problem then , i will check it and inform you? Thanks for letting me know!

Knowledgelocater avatar Jan 09 '25 16:01 Knowledgelocater

@mknet if there is still problem then , i will check it and inform you? Thanks for letting me know!

Yes, @Knowledgelocater, the problem still remains. Any hints?

mknet avatar Jan 10 '25 20:01 mknet

If you are using macbook M series chips, this is due to the incompatibility of the boxes you are choosing with your provider and architecture.

Assuming you are using virtualbox with macbook M series chips, you need to look for these types of boxes:

  • Architecture: arm64
  • Provider: Virtualbox Image

You can test out this box. It worked for me with virtualbox.

Do note: Virtualbox has very few official vagrant boxes that support ARM64, so if you want the ability to use many, try switching to the qemu provider.

GDivino avatar Jan 22 '25 11:01 GDivino

@GDivino yes, I came across that one. Was really hoping to find one by a more well known maintainer before I use it at work. But, thanks for restating the problem. It seems to me that it was only partially understood based on some of the comments on this issue.

jeromecovington avatar Jan 22 '25 14:01 jeromecovington

This worked for me https://portal.cloud.hashicorp.com/vagrant/discover/bento/ubuntu-22.04

try this

unifiedcontroller.vm.box = "bento/ubuntu-22.04"
unifiedcontroller.vm.box_version = "202502.21.0" 
unifiedcontroller.vm.box_architecture = "arm64"

jainsiddharth99 avatar Jun 25 '25 05:06 jainsiddharth99

unifiedcontroller.vm.box = "bento/ubuntu-22.04"
unifiedcontroller.vm.box_version = "202502.21.0" 
unifiedcontroller.vm.box_architecture = "arm64"

Any chance of a (tested) PR?

peterbarker avatar Jun 25 '25 06:06 peterbarker

Although late, I just wanted to add my working vagrant config for an M4 Mac running 15.6.1 based on this thread:

  config.vm.define "noble", primary: true do |noble|
    noble.vm.box = "bento/ubuntu-22.04"
    noble.vm.box_version = "202508.03.0"
    noble.vm.provision :shell, path: "Tools/vagrant/initvagrant.sh"
    noble.vm.provider "virtualbox" do |vb|
      vb.name = "ArduPilot (noble)"
    end
    noble.vm.boot_timeout = 1200
  end

As a further FYI, once the VM was running, I couldn't get Mavproxy to forward out of the VM to the Mac host over UDP. So I ended up starting the sim_vehicle.py with --no-mavproxy switch, and configured VirtualBox to port forward tcp:5760 and ran MavProxy on my MacOS host: mavproxy.py --master=tcp:127.0.0.1:5760 --out=udp:0.0.0.0:14550. QGC then connected immediately.

nstansbury avatar Oct 05 '25 08:10 nstansbury

Although late, I just wanted to add my working vagrant config for an M4 Mac running 15.6.1 based on this thread:

  config.vm.define "noble", primary: true do |noble|
    noble.vm.box = "bento/ubuntu-22.04"
    noble.vm.box_version = "202508.03.0"
    noble.vm.provision :shell, path: "Tools/vagrant/initvagrant.sh"
    noble.vm.provider "virtualbox" do |vb|
      vb.name = "ArduPilot (noble)"
    end
    noble.vm.boot_timeout = 1200
  end

As a further FYI, once the VM was running, I couldn't get Mavproxy to forward out of the VM to the Mac host over UDP. So I ended up starting the sim_vehicle.py with --no-mavproxy switch, and configured VirtualBox to port forward tcp:5760 and ran MavProxy on my MacOS host: mavproxy.py --master=tcp:127.0.0.1:5760 --out=udp:0.0.0.0:14550. QGC then connected immediately.

Could you create a PR against master for that, please? Given the version pin it might be a good idea to use noble-mac-m4 for the machine name?

peterbarker avatar Oct 05 '25 11:10 peterbarker