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

Cannot install in GitHub Actions using go install #2053

Open
Cavaler opened this issue Apr 26, 2024 · 8 comments
Open

Cannot install in GitHub Actions using go install #2053

Cavaler opened this issue Apr 26, 2024 · 8 comments

Comments

@Cavaler
Copy link

Cavaler commented Apr 26, 2024

I'm trying to install gomplate in GHA with the following:

      - name: Setup Go
        uses: actions/setup-go@v5
        with:
          go-version: 'stable'

      - name: Install gomplate
        run: |
          go get github.com/hairyhenderson/gomplate/v4/cmd/gomplate@latest
          gomplate --help

But I get an error:

Run go install github.com/hairyhenderson/gomplate/v4/cmd/gomplate@latest
go: downloading github.com/hairyhenderson/gomplate v3.5.0+incompatible
go: downloading github.com/hairyhenderson/gomplate/v4 v4.0.0-pre-2
go: github.com/hairyhenderson/gomplate/v4/cmd/gomplate@latest (in github.com/hairyhenderson/gomplate/v4@v4.0.0-pre-2):
	The go.mod file for the module providing named packages contains one or
	more replace directives. It must not contain directives that would cause
	it to be interpreted differently than if it were the main module.

Either this should be fixed in some way, or this installation method should be removed from documentation.

@AndrewSav
Copy link
Contributor

AndrewSav commented May 8, 2024

@Cavaler can you point out where you found go get in the documentation? I grepped it and it returned nothing. I also checked the Installing page and could not locate it there either. What documentation are you referring to?

@AndrewSav
Copy link
Contributor

AndrewSav commented May 8, 2024

I tried it without github action, from command line, according to the Installing page I linked above and I got:

go install github.com/hairyhenderson/gomplate/v4/cmd/gomplate@latest 
go: downloading github.com/hairyhenderson/gomplate/v4 v4.0.0-pre-2
go: downloading github.com/hairyhenderson/gomplate v3.5.0+incompatible
go: github.com/hairyhenderson/gomplate/v4/cmd/gomplate@latest (in github.com/hairyhenderson/gomplate/v4@v4.0.0-pre-2):
	The go.mod file for the module providing named packages contains one or
	more replace directives. It must not contain directives that would cause
	it to be interpreted differently than if it were the main module.

Which is more or less the same as in OP.

The go team does not want you to use replace

@hairyhenderson
Copy link
Owner

@Cavaler Maybe this (third party) action works for you? https://github.com/jason-dour/action-setup-gomplate

The replace directive is currently necessary due to go-git/go-git#416. The alternative will be to switch to my fork entirely, but I'm not super excited about doing that.

Ultimately, the most reliable way to install gomplate in a GitHub Action probably just involves downloading the released binary.


Incidentally I'm confused why this line is logged:

go: downloading github.com/hairyhenderson/gomplate v3.5.0+incompatible

There's nothing that depends on that module in the current codebase... 🤔

@jlambert121
Copy link

I'm running into this same issue when trying to incorporate gomplate into my project and calling gomplate.RunTemplates. A very quick look does look like it would be annoying to switch this package so I understand that, curious if there's any other ideas to get around this for someone using this more as a library.

(And thanks for your work on this - exactly what I was needing to solve a scaffolding problem against a directory!)

@hairyhenderson
Copy link
Owner

@jlambert121 if you're incorporating it into your project, the easy thing to do is to just copy my replace line into your project... I think that should just work?

@jlambert121
Copy link

@hairyhenderson unfortunately it seems to be just mad at yours rather than seeing mine says the same thing.

$ go install github.com/hairyhenderson/gomplate/v4/cmd/gomplate@latest
go: github.com/hairyhenderson/gomplate/v4/cmd/gomplate@latest (in github.com/hairyhenderson/gomplate/v4@v4.0.0-pre-2):
	The go.mod file for the module providing named packages contains one or
	more replace directives. It must not contain directives that would cause
	it to be interpreted differently than if it were the main module.

@hairyhenderson
Copy link
Owner

@jlambert121 use go get instead of go install if you're adding it to a project

@jlambert121
Copy link

🤦 sorry, command history and I didn't look at it close enough!

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

4 participants