diff --git a/lib/core/rancher/step.sh b/lib/core/rancher/step.sh
index bdf4482..f99c43b 100644
--- a/lib/core/rancher/step.sh
+++ b/lib/core/rancher/step.sh
@@ -49,15 +49,15 @@ function ih::setup::core.rancher::test() {
return 1
fi
- # Use vz instead of qemu on macOS 13.3 to resolve m3 mac issues.
- # See: https://github.com/lima-vm/lima/issues/1996
- # Also: https://github.com/rancher-sandbox/rancher-desktop/blob/fcffd3cc071a9414dcf03c895792b5142116ffd4/pkg/rancher-desktop/main/commandServer/settingsValidator.ts#L320-L330
+ # Use vz (requires macOS >=13.3) instead of qemu on M3 macs to resolve issues.
+ # More details: https://github.com/lima-vm/lima/issues/1996
local macos_version=$(ih::arch::get_macos_version)
- if (( $(echo "$macos_version >= 13.3" | bc -l) )); then
- if grep -q "vz" "$PLIST_DST"; then
- ih::log::debug "The PLIST file already uses 'vz' for Virtualization."
- else
- ih::log::debug "The PLIST file needs to be updated to use 'vz'."
+ if ih::arch::is_m3_mac; then
+ if (( $(echo "$macos_version < 13.3" | bc -l) )); then
+ ih::log::error "macOS version 13.3 or higher is required for M3 Macs."
+ return 1
+ elif ! grep -q "vz" "$PLIST_DST"; then
+ ih::log::debug "The PLIST file needs to be updated to use 'vz' for M3 Macs."
return 1
fi
fi
@@ -133,11 +133,14 @@ function ih::setup::core.rancher::install() {
fi
fi
- # Use vz instead of qemu on macOS 13.3 to resolve m3 mac issues.
- local macos_version=$(ih::arch::get_macos_version)
- if (( $(echo "$macos_version >= 13.3" | bc -l) )); then
- if ! grep -q "vz" "$PLIST_DST"; then
- ih::log::debug "Updating PLIST to use 'vz' for Virtualization."
+ # Use vz (requires macOS >=13.3) instead of qemu on M3 macs to resolve issues.
+ # More details: https://github.com/lima-vm/lima/issues/1996
+ if ih::arch::is_m3_mac; then
+ if (( $(echo "$macos_version < 13.3" | bc -l) )); then
+ ih::log::error "macOS version 13.3 or higher is required for M3 Macs."
+ return 1 # Abort the installation for M3 Macs
+ elif ! grep -q "vz" "$PLIST_DST"; then
+ ih::log::debug "Updating PLIST to use 'vz' for Virtualization for M3 Macs."
sudo sed -i '' 's/qemu<\/string>/vz<\/string>/g' "$PLIST_DST"
fi
fi
diff --git a/lib/utils/arch.sh b/lib/utils/arch.sh
index 65589bd..0c6a65c 100644
--- a/lib/utils/arch.sh
+++ b/lib/utils/arch.sh
@@ -25,3 +25,12 @@ ih::arch::mbrew() {
ih::arch::get_macos_version() {
sw_vers -productVersion | awk -F '.' '{ printf("%d.%d\n", $1, $2) }'
}
+
+ih::arch::is_m3_mac() {
+ local hw_model=$(sysctl -n machdep.cpu.brand_string)
+ if [[ "$hw_model" == *"M3"* ]]; then
+ return 0 # This is an M3 Mac.
+ else
+ return 1 # This is not an M3 Mac.
+ fi
+}