Skip to content

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

Closed

Description

@ydnar

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!

Activity

  1. changed the title [-]Feature request: always add GOBIN to PATH[/-] [+]Feature request: add GOBIN to PATH even if a version isn't installed[/+] on Apr 3, 2020
  2. fsilva3 commented on May 11, 2020

    @fsilva3

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

  3. ydnar commented on May 11, 2020

    @ydnar
    Author

    @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?

  4. remorses commented on Jun 6, 2020

    @remorses

    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

  5. subins2000 commented on Nov 8, 2020

    @subins2000

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

  6. bryanmacfarlane commented on Nov 9, 2020

    @bryanmacfarlane
    Contributor

    @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

  7. subins2000 commented on Nov 9, 2020

    @subins2000

    @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
    
  8. bryanmacfarlane commented on Nov 9, 2020

    @bryanmacfarlane
    Contributor

    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?

  9. leighmcculloch commented on Dec 3, 2020

    @leighmcculloch

    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
    
  10. leighmcculloch commented on Dec 3, 2020

    @leighmcculloch

    @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');

  11. leighmcculloch commented on Dec 4, 2020

    @leighmcculloch

    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.

  12. Sergey-Murtazin commented on Oct 19, 2021

    @Sergey-Murtazin
    Contributor

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

  13. ydnar commented on Oct 19, 2021

    @ydnar
    Author

    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
  14. leighmcculloch commented on Nov 7, 2021

    @leighmcculloch

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

  15. added
    feature requestNew feature or request to improve the current logic
    and removed
    enhancementNew feature or request
    on Nov 9, 2021
  16. added a commit that references this issue on Dec 19, 2022
  17. self-assigned this
    on Feb 20, 2023
  18. dmitry-shibanov commented on Mar 16, 2023

    @dmitry-shibanov
    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

Metadata

Metadata

Labels

feature requestNew feature or request to improve the current logic

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions