File tree Expand file tree Collapse file tree 3 files changed +39
-0
lines changed Expand file tree Collapse file tree 3 files changed +39
-0
lines changed Original file line number Diff line number Diff line change 8
8
"runtime"
9
9
"strings"
10
10
11
+ "github.com/lima-vm/lima/pkg/osutil"
11
12
"github.com/lima-vm/lima/pkg/store/dirnames"
12
13
"github.com/lima-vm/lima/pkg/version"
13
14
"github.com/mattn/go-isatty"
@@ -60,6 +61,12 @@ func newApp() *cobra.Command {
60
61
if debug {
61
62
logrus .SetLevel (logrus .DebugLevel )
62
63
}
64
+
65
+ if osutil .IsBeingRosettaTranslated () {
66
+ // running under rosetta would provide inappropriate runtime.GOARCH info, see: https://github.com/lima-vm/lima/issues/543
67
+ return errors .New ("limactl is running under rosetta, please reinstall lima with native arch" )
68
+ }
69
+
63
70
if runtime .GOOS == "windows" && isatty .IsCygwinTerminal (os .Stdout .Fd ()) {
64
71
formatter := new (logrus.TextFormatter )
65
72
// the default setting does not recognize cygwin on windows
Original file line number Diff line number Diff line change
1
+ package osutil
2
+
3
+ import (
4
+ "fmt"
5
+
6
+ "github.com/sirupsen/logrus"
7
+ "golang.org/x/sys/unix"
8
+ )
9
+
10
+ func IsBeingRosettaTranslated () bool {
11
+ ret , err := unix .SysctlUint32 ("sysctl.proc_translated" )
12
+ if err != nil {
13
+ const fallback = false
14
+ if err == unix .ENOENT {
15
+ return false
16
+ }
17
+
18
+ err = fmt .Errorf (`failed to read sysctl "sysctl.proc_translated": %w` , err )
19
+ logrus .WithError (err ).Warnf ("failed to detect whether running under rosetta, assuming %v" , fallback )
20
+ return fallback
21
+ }
22
+
23
+ return ret != 0
24
+ }
Original file line number Diff line number Diff line change
1
+ //go:build !darwin
2
+ // +build !darwin
3
+
4
+ package osutil
5
+
6
+ func IsBeingRosettaTranslated () bool {
7
+ return false
8
+ }
You can’t perform that action at this time.
0 commit comments