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

Feature request: add GOBIN to PATH even if a version isn't installed #49

Closed
ydnar opened this issue Apr 2, 2020 · 14 comments
Closed

Feature request: add GOBIN to PATH even if a version isn't installed #49

ydnar opened this issue Apr 2, 2020 · 14 comments
Assignees
Labels
feature request New feature or request to improve the current logic

Comments

@ydnar
Copy link

ydnar commented Apr 2, 2020

Request: setup-go should always add GOBIN to PATH, even if it uses the default Go installed in the environment. This would mirror how it always sets up Go matchers.

Per thread here: #39 (comment)

Thanks!

@bryanmacfarlane bryanmacfarlane changed the title Feature request: always add GOBIN to PATH Feature request: add GOBIN to PATH even if a version isn't installed Apr 3, 2020
@bryanmacfarlane bryanmacfarlane self-assigned this Apr 3, 2020
@bryanmacfarlane bryanmacfarlane added the enhancement New feature or request label Apr 3, 2020
@filipesilvaa
Copy link

@ydnar I tried now with new version (setup-go@v2), and apparently it's adding GOBIN to PATH, working well at my repository.

@ydnar
Copy link
Author

ydnar commented May 11, 2020

@ydnar I tried now with new version (setup-go@v2), and apparently it's adding GOBIN to PATH, working well at my repository.

Did you specify go-version?

@remorses
Copy link

remorses commented Jun 6, 2020

I had the same issue, after running go mod download the packages bins are not in path, using version v2

Edit: looks like go mod download does not put binaries in GOBIN

@subins2000
Copy link

Seems like using this one-liner - uses: actions/setup-go@v2 just for setting the env won't work out

@bryanmacfarlane
Copy link
Member

bryanmacfarlane commented Nov 9, 2020

@subins2000 adding that one liner (setup-go@v2) does add gobin to the path.

Just tried. Look at the path step in this run.

The second entry of the path in this example has /home/runner/go/bin added

Screen Shot 2020-11-09 at 9 05 39 AM

@subins2000
Copy link

subins2000 commented Nov 9, 2020

@bryanmacfarlane It didn't work for me on a Windows host and bash, so had to do :

echo "::set-env name=GOPATH::$(go env GOPATH)"
echo "::add-path::$(go env GOPATH)/bin"

The above is deprecated in the latest images. Using this now :

echo $(go env GOPATH)/bin >> $GITHUB_PATH

@bryanmacfarlane
Copy link
Member

bryanmacfarlane commented Nov 9, 2020

I'll try it out on windows.

The code is adding it to the path (it actually does your second line of add-path - even on windows). Note it does not set GOPATH as that's a < go 1.12 and pre go modules concept. If that's your use case, you can set.

It also doesn't set GOBIN (but go/bin is added to path). do we think it should?

@leighmcculloch
Copy link

In my builds this yml is not resulting in GOBIN being in the PATH. If I go get tools they install fine but aren't available on the PATH.

This is a snippet from my workflow:

name: build
on: [push, pull_request]
jobs:
  test:
    runs-on: ubuntu-latest
    steps:
    - uses: actions/setup-go@v2
    - uses: actions/setup-ruby@v1
    - run: go get github.com/mattn/goreman
    - run: goreman ...

This is what I see if I echo PATH:

/opt/hostedtoolcache/Ruby/2.7.2/x64/bin:/home/linuxbrew/.linuxbrew/bin:/home/linuxbrew/.linuxbrew/sbin:/opt/pipx_bin:/usr/share/rust/.cargo/bin:/home/runner/.config/composer/vendor/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

@leighmcculloch
Copy link

@bryanmacfarlane I'm not sure how it works for you, because in your output there is the line Added go to the path, and the only place that line is printed is below and is wrapped in a if (versionSpec):

setup-go/src/main.ts

Lines 23 to 31 in d0c5def

if (versionSpec) {
let token = core.getInput('token');
let auth = !token || isGhes() ? undefined : `token ${token}`;
const installDir = await installer.getGo(versionSpec, stable, auth);
core.exportVariable('GOROOT', installDir);
core.addPath(path.join(installDir, 'bin'));
core.info('Added go to the path');

@leighmcculloch
Copy link

I've opened a PR #89 that adds GOBIN to PATH regardless of whether a version is specified. I tested it on my own repo and it worked in both cases.

mefellows added a commit to pactflow/terraform-provider-pact that referenced this issue Jan 22, 2021
mefellows added a commit to pactflow/terraform-provider-pact that referenced this issue Jan 22, 2021
mefellows added a commit to pactflow/terraform-provider-pact that referenced this issue Jan 22, 2021
haya14busa added a commit to reviewdog/action-suggester that referenced this issue Jun 26, 2021
@Sergey-Murtazin
Copy link
Contributor

Hi @ydnar ! Sorry for the late response!
Could you please clarify if the issue is still actual for you?
Thanks!

@ydnar
Copy link
Author

ydnar commented Oct 19, 2021

Hi @ydnar ! Sorry for the late response!
Could you please clarify if the issue is still actual for you?
Thanks!

Honestly, I haven’t checked. All of our uses of actions/setup-go specify version: ^1 now:

      - name: Set up Go
        uses: actions/setup-go@v2
        with:
          go-version: ^1

@leighmcculloch
Copy link

@Sergey-Murtazin PR with a fix is open at #89.

@Sergey-Murtazin Sergey-Murtazin added feature request New feature or request to improve the current logic and removed enhancement New feature or request labels Nov 9, 2021
walles added a commit to walles/moar that referenced this issue Dec 19, 2022
@MaksimZhukov MaksimZhukov self-assigned this Feb 20, 2023
@dmitry-shibanov
Copy link
Contributor

Hello everyone. We added this logic in new major action version. For now I'm going to close the issue. If you have any concerns feel free to ping us.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feature request New feature or request to improve the current logic
Projects
None yet
Development

Successfully merging a pull request may close this issue.

9 participants