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

setup-go does not work on macos-14 (M1) #454

Closed
2 of 5 tasks
Le0Developer opened this issue Feb 6, 2024 · 6 comments
Closed
2 of 5 tasks

setup-go does not work on macos-14 (M1) #454

Le0Developer opened this issue Feb 6, 2024 · 6 comments
Assignees
Labels
bug Something isn't working

Comments

@Le0Developer
Copy link

Description:
actions/setup-go is erroring when used on macos-14 (M1 runners)

Action version:
v5

Platform:

  • Ubuntu
  • macOS
  • Windows

Runner type:

  • Hosted
  • Self-hosted

Tools version:

Repro steps:
https://github.com/Le0Developer/go-setup-macos-14

Expected behavior:
Should build & print hello world.

Actual behavior:

Setup go version spec 
Warning: go-version input was not specified. The action will try to use pre-installed version.
/bin/sh: version: command not found
Error: Command failed:  version
/bin/sh: version: command not found
@Le0Developer Le0Developer added bug Something isn't working needs triage labels Feb 6, 2024
@HarithaVattikuti
Copy link
Contributor

Hello @Le0Developer
Thank you for creating this issue. We will investigate it and get back to you as soon as we have some feedback.

@gaby
Copy link

gaby commented Feb 10, 2024

The action should be using the darwin-arm64 ? @Le0Developer have you tried specifying a version?

According to the official docs the arm64 m1 based images do not come with golang preinstalled.

Source: https://github.com/actions/runner-images/blob/main/images/macos/macos-14-arm64-Readme.md

Try the following and it should work:

jobs:
  build:
    name: Build on macOS 14 (M1)
    runs-on: macos-14
  steps:
    - uses: actions/checkout@v4
    - uses: actions/setup-go@v5
      with:
        go-version: '1.22.x'
        check-latest: true
    - run: go run hello.go

@gaby
Copy link

gaby commented Feb 10, 2024

@HarithaVattikuti This action should default to installing the latest Golang on darwin platforms.

@matthewhughes934
Copy link

@HarithaVattikuti This action should default to installing the latest Golang on darwin platforms.

🤔 how should this action behaviour in general when Golang is not installed in the system and not version is given. At the moment: the line

const goVersion = (cp.execSync(`${goPath} version`) || '').toString();
will have goPath == '' and run:

cp.execSync(` version`)

Resulting in the rather unclear error /bin/sh: version: command not found (i.e. the error from the issue)

In this case I suppose the action could:

@Le0Developer
Copy link
Author

Le0Developer commented Apr 9, 2024

The action should be using the darwin-arm64 ? @Le0Developer have you tried specifying a version?

According to the official docs the arm64 m1 based images do not come with golang preinstalled.

Source: https://github.com/actions/runner-images/blob/main/images/macos/macos-14-arm64-Readme.md

I'd expect setup-go to setup go, regardless of if it's already installed or not.

Try the following and it should work:

jobs:
  build:
    name: Build on macOS 14 (M1)
    runs-on: macos-14
  steps:
    - uses: actions/checkout@v4
    - uses: actions/setup-go@v5
      with:
        go-version: '1.22.x'
        check-latest: true
    - run: go run hello.go

That does work! I was expecting it to default to the latest version, but that works!

@aparnajyothi-y
Copy link

aparnajyothi-y commented Apr 15, 2024

Hello @Le0Developer, Apologies for the delay in the response and we have investigated the issue and we are able to reproduce the error with go-version input was not specified in the workflow file. The go-version input should specify the version of Go that we want to set up. If it's not provided, the action tries to use a pre-installed version, which seems to be failing.

Here is an example of how to specify the go-version input:

  • name: Set up Go
    uses: actions/setup-go@v5
    with:
    go-version: 1.12 # Replace with your desired Go version

Thank you for the confirmation and we have checked your workflow and the action is successful after adding the go-version.
Hello @gaby, actions/setup-go action can indeed be set up to install the latest version of Go. However, it doesn't default to installing the latest version unless you specify it.

To set up the latest stable version of Go, you can use the @latest version specifier in your workflow file:

  • name: Set up Go
    uses: actions/setup-go@v5
    with:
    go-version: '1.12'
    check-latest: true

Proceeding to close this as the issue resolved with go-version. Please feel free to reach us in case of any further clarifications to reopen this issue.

matthewrobertson added a commit to GoogleCloudPlatform/functions-framework-go that referenced this issue Apr 29, 2024
According to actions/setup-go#454 this should resolve the issues installing go in the macos workflows
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

6 participants