cirruslabs / tart

macOS and Linux VMs on Apple Silicon to use in CI and other automations
https://tart.run
Other
3.8k stars 112 forks source link

Error: UnsupportedArchitectureError() on Mac M1 #729

Closed Villafruela closed 7 months ago

Villafruela commented 7 months ago

Hi,

I've installed tart with brew and it works.

When i try to install any of the linux repo of the Quick Start Guide (debian, ubuntu, or fedora) i got this error message : Error: UnsupportedArchitectureError()

I'm using a macbook air M1 / 16GO of RAM under Sonoma

Thanks for any help

fkorotkov commented 7 months ago

Did you happen to install an Intel version of Tart?

Villafruela commented 7 months ago

Nope, all the commands in the terminal works, it's only when i do : tart run nameofmydistro that i get the error message... (wich is quite odd, i understand...) i cant also do a tart --help

edigaryev commented 7 months ago

Have you installed Tart from homebrew/core by a chance?

What is the tart --version output?

Villafruela commented 7 months ago

yes i followed the tutorial and used Homebrew. version is 2.5.0

edigaryev commented 7 months ago

@Villafruela which VM image are you trying to run?

UnsupportedArchitectureError is thrown when the VM's architecture doesn't match the host one.

You can also check the contents of ~/.tart/vms/<VM>/config.json.

Villafruela commented 7 months ago

Oh i see, does that mean that the ones in the quick start guide are not for arm processor (that would be odd as tart is for Mx Apple Silicon) ?

i've tried the 3 linux : ghcr.io/cirruslabs/ubuntu:latest ghcr.io/cirruslabs/debian:latest ghcr.io/cirruslabs/fedora:latest

none of them worked.

edigaryev commented 7 months ago

i've tried the 3 linux

These are for arm64, so the only remaining option I see is that you've somehow installed amd64 version of Tart, as @fkorotkov suggested.

What does the output of:

file /opt/homebrew/Cellar/tart/2.5.0/libexec/tart.app/Contents/MacOS/tart

...show?

Villafruela commented 7 months ago

Hi thanks for helping me solve that problem. I got this : /opt/homebrew/Cellar/tart/2.5.0/libexec/tart.app/Contents/MacOS/tart: cannot open `/opt/homebrew/Cellar/tart/2.5.0/libexec/tart.app/Contents/MacOS/tart' (No such file or directory) So i located tart wich is there on my computer : /usr/local/Cellar/tart/2.5.0/libexec/tart.app/Contents/MacOS/tart. the file command return this : /usr/local/Cellar/tart/2.5.0/libexec/tart.app/Contents/MacOS/tart: Mach-O 64-bit executable x86_64

edigaryev commented 7 months ago

@Villafruela it's likely that you've installed Tart using an amd64 version of Homebrew.

brew config might reveal some additional details.

Consider uninstalling Homebrew and installing it again, without using any arch -x86_64 wrapper.

Villafruela commented 7 months ago

Ok thanks,

So i've been digging and find out the problem though i could not solve it.

It appears that the terminal on macOS can be used in "intel mode" via roseta 2 or "arm mode". you can check the mode you're in with the command : arch It will return i386 if you're in intel mode or arm64 (native) if you're in arm mode. You can force the use of your shell in native or intel mode with the command :

/usr/bin/arch -arm64 for arm /usr/bin/arch -x86_64 for intel

to make things easier i added 2 lines in my ".zshrc" config file via the command (i explain in details so that others can do it as well ) :

nano ~/.zshrc

i added these 2 lines :

alias arm="env /usr/bin/arch -arm64 /bin/zsh --login" alias intel="env /usr/bin/arch -x86_64 /bin/zsh --login"

then saved the .zshrc file and closed it.

so now, in the terminal, if i type arm i go in native mode (i can verify with arch that will return "arm64") and if i type intel i go in intel mode (arch will return "i386")

So i made a full reinstall of brew in native mode and then tried the brew install cirruslabs/cli/tart. And.... it didn't worked but i noticed that although i'm in native mode (arm), brew still tries to download the amd64 version and not the arm64 version. I get : Downloading https://github.com/cirruslabs/tart/releases/download/2.6.0/tart-amd64.tar.gz instead of : Downloading https://github.com/cirruslabs/tart/releases/download/2.6.0/tart-arm64.tar.gz

Somehow, the detection of the Arm architecture doesn't work in https://github.com/cirruslabs/homebrew-cli/blob/master/tart.rb on line 14

i always end up with the "tart-amd64.tar.gz" installation.

i don't know ruby so i won't be of much help, but Is there a way to run the brew install with the arm archive ? Something like : brew install cirruslabs/cli/tart -arm64 ?

Villafruela commented 7 months ago

Ok i nailed it !

I had 2 installations of homebrew one in arm mode in /op/homebrew and one in /usr/local/homebrew for the intel version. The default version (don't ask why!!) is the intel one, so i kept installing/uninstalling the arm one while only using the intel one (duhh !).

So i uninstalled homebrew twice : the first one uninstalled the arm version, the second the intel version. Then reinstalled on native mode and checked with brew config.

On the Rosetta line i now have a nice : Rosetta 2: false

And now it works like a charm...

Villafruela commented 7 months ago

Thks a lot for your help @edigaryev and @fkorotkov !