hairyhenderson/gomplate

Cannot install in GitHub Actions using go install

Cavaler opened this issue · 8 comments

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.

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

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

@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... 🤔

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!)

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

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

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

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