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

Binaries installed via go install are not accessible on path #27

Closed
JeremyLoy opened this issue Nov 3, 2019 · 12 comments
Closed

Binaries installed via go install are not accessible on path #27

JeremyLoy opened this issue Nov 3, 2019 · 12 comments
Assignees

Comments

@JeremyLoy
Copy link

Hi,

I'm hoping to migrate my open source library from Travis to Github Actions, but I've hit a snag - I'm unable to run most of my build checks. I use golint and goimports, both tools installed via go install.

These binaries are not found on any OS that I've tried, (windows, ubuntu, macOS) which led me to this repo where I discovered that GOBIN was not being added to PATH.

The fix should be as simple as adding GOPATH/bin to PATH

@JeremyLoy
Copy link
Author

actually after further investigation it looks like the env and path are already getting set, but to the wrong values.

Below are some screenshots of the MacOS setup. go env is correctly saying that GOPATH is User/runner/go. This means that GOBIN will default to User/runner/go/bin since it is unset.

If we look at PATH, it seems that /usr/local/go/bin is getting set. By my understanding, this is not the correct value for any operating system, definitely not macOS.

image

image

@kjk
Copy link

kjk commented Nov 3, 2019

I agree this should work by default but for now you can add to each step:

export PATH=${PATH}:`go env GOPATH`/bin

See https://presstige.io/p/Using-GitHub-Actions-with-Go-2ca9744b531f4f21bdae9976d1ccbb58#e86c1c15-6f43-4f43-935f-37895bd14208 for a fuller example (I use that for running staticcheck)

(just a tip, I'm not the maintainer).

@devigned
Copy link

devigned commented Nov 4, 2019

setup-go/src/installer.ts

Lines 119 to 121 in 75259a5

if (goBin) {
core.exportVariable('GOBIN', goBin);
}

Should have an else and export the default GOBIN into the path and set the PATH to include the GOBIN.

@JeremyLoy
Copy link
Author

In addition to that @devigned I think the ‘GOPATH’ statement two lines above that needs an ‘else’

@devigned
Copy link

devigned commented Nov 4, 2019

Agreed. If nothing is overridden, Golang defaults should be honored.

@lmittmann
Copy link

Duplicate of #14

@bryanmacfarlane
Copy link
Member

actually after further investigation it looks like the env and path are already getting set, but to the wrong values.

Agreed. Will fix.

@bryanmacfarlane bryanmacfarlane self-assigned this Feb 7, 2020
8Mobius8 added a commit to 8Mobius8/go-habits that referenced this issue Feb 24, 2020
@bryanmacfarlane
Copy link
Member

This should be fixed in @v2-beta version of this action. See #14

@ARolek
Copy link

ARolek commented Apr 10, 2020

I just hit this problem and upgrading to v2-beta fixed this problem for me.

@bryanmacfarlane
Copy link
Member

Awesome to hear. I’ll probably release v2 Monday

@ARolek
Copy link

ARolek commented Apr 10, 2020

Nice! Thanks for putting this action together. I have been using it with a few projects.

@davidgraca
Copy link

Hi everyone, ressurecting the dead here...
Let's start by the beggining, you:

  • put that on your gh action

- name: Setup Go environment uses: actions/[email protected]

  • go check go env

GOPATH="/home/runner/go"

  • go check $PATH

$PATH: /home/runner/.local/bin:/opt/pipx_bin:/home/runner/.cargo/bin:/home/runner/.config/composer/vendor/bin:/usr/local/.ghcup/bin:/home/runner/.dotnet/tools:/snap/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games:/snap/bin

  • and see that all your go installs are on GOPATH /bin

I added to my action:
export PATH=${PATH}:go env GOPATH/bin

and now it works fine.
Would it be possible to refix this?
Thanks

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

7 participants