Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Default install does not honor GOARCH #52

Closed
mdelapenya opened this issue Aug 3, 2022 · 6 comments
Closed

Default install does not honor GOARCH #52

mdelapenya opened this issue Aug 3, 2022 · 6 comments

Comments

@mdelapenya
Copy link

I'm trying to install Go on my Macbook Pro M1 with GVM, but it always installs the AMD64 version of Go:

$ eval "$(gvm 1.17.8)"
$ go version
go version go1.17.8 darwin/amd64

It's not until I add the GOARCH variable when it respects the architecture of my machine:

$ GOARCH=arm64 eval "$(gvm 1.17.8)"
$ go version                       
go version go1.17.8 darwin/arm64
@mdelapenya
Copy link
Author

mdelapenya commented Aug 3, 2022

I'd also add installation instructions in the docs for ARM :)

curl -sL -o /usr/local/bin/gvm https://github.com/andrewkroh/gvm/releases/download/v0.4.1/gvm-darwin-arm64

@andrewkroh
Copy link
Owner

andrewkroh commented Aug 3, 2022

It does not use GOARCH. It is supposed to support the --arch flag and GVM_ARCH env var. But I see a bug in setting that prevent its use (will fix).

gvm flags can be set via environment variables by setting GVM_<flag>. For example --http-timeout can be set via GVM_HTTP_TIMEOUT=10m.

Optional flags:
  -h, --help                   Show context-sensitive help (also try --help-long and --help-man).
  -d, --debug                  Enable debug logging to stderr.
      --os=OS                  Go binaries target os.
      --arch=ARCH              Go binaries target architecture.

You must already have the darwin/amd64 version of gvm installed, because it defaults to using the architecture of gvm (via runtime.GOARCH). So if you install the darwin/arm64 release then it should default to arm64.

@andrewkroh
Copy link
Owner

andrewkroh commented Aug 3, 2022

Relates: #53 (fixes --arch)

@andrewkroh
Copy link
Owner

It's not until I add the GOARCH variable when it respects the architecture of my machine:

GOARCH=arm64 eval "$(gvm 1.17.8)"

In general, that environment variable won't be made available to the subshell. So it would be surprising to have GOARCH affect anything within that subshell.

@andrewkroh
Copy link
Owner

I tested the fix for the --arch flag and it is working. I also updated the README to include MacOS arm64 commands.

On a M1 mac I tested using an amd64 gvm binary with the --arch flag to install an arm64 Go version.

% gvm -d --arch=arm64 1.19
DEBU[0000] GVM version: v0.4.2-0.20220803200806-2fe721bcadc0 
DEBU[0000] GVM commit: h1:/rI3EYbmCdpCyPXqoNjBOifkcWFmyhke0iR/jQuxM+A= 
DEBU[0000] GVM arch: amd64                                               # <-- Architecture of gvm binary.
DEBU[0000] Using Go version 1.19                         package=main
export GOROOT="/Users/akroh/.gvm/versions/go1.19.darwin.arm64"
export PATH="/Users/akroh/.gvm/versions/go1.19.darwin.arm64/bin:$PATH"

The env var works too:

GVM_ARCH=arm64 gvm -d 1.19
DEBU[0000] GVM version: v0.4.2-0.20220803200806-2fe721bcadc0 
DEBU[0000] GVM commit: h1:/rI3EYbmCdpCyPXqoNjBOifkcWFmyhke0iR/jQuxM+A= 
DEBU[0000] GVM arch: amd64                              
DEBU[0000] Using Go version 1.19                         package=main
export GOROOT="/Users/akroh/.gvm/versions/go1.19.darwin.arm64"
export PATH="/Users/akroh/.gvm/versions/go1.19.darwin.arm64/bin:$PATH"

Or when using eval:

eval "$(GVM_ARCH=arm64 gvm -d 1.19)"

eval "$(gvm --arch=arm64 -d 1.19)"

@andrewkroh
Copy link
Owner

I'd also add installation instructions in the docs for ARM :)

I forgot we have a universal binary for mac so I now changed the readme to use that.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants