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

1.11.0 causes errors with //go:generate packer-sdc mapstructure-to-hcl2 #132

Closed
NorseGaud opened this issue Sep 2, 2022 · 1 comment
Closed

Comments

@NorseGaud
Copy link

Details: hashicorp/packer-plugin-sdk#128

@apparentlymart
Copy link
Collaborator

apparentlymart commented Sep 2, 2022

Hello! Thanks for reporting this.

I also saw a problem like this when running an old build of "stringer" in a codebase containing go-cty.

In the interests of making this searchable, I'll copy the error message you saw from the other issue into here:

Unexpected package creation during export data loading

The problem seems to be upstream, tracked in golang/go#51629. It will occur as soon as there's at least one package in your codebase which uses Go 1.18 type parameters, and so I guess go-cty was the first module in your dependency tree to begin using those features. If another dependency had happened to start using type parameters first then it would've been that upgrade which would've encountered this error.

The fix was in the golang.org/x/tools module, which your code generator seems to depend on. If that's true then I think the resolution steps would be to:

  • Upgrade to golang.org/x/tools v0.1.12
  • If you're using a pre-built executable of your generator in your GOBIN directory, then you'll need to rebuild that with the upgraded golang.org/x/tools to make it work. If you are running it with go run ... then it should automatically notice that the dependency has changed and so rebuild it.

This module doesn't itself depend on golang.org/x/tools (directly or indirectly), so I can't force a newer version of that module through a change in this repository. The dependency must unfortunately be upgraded in the module which contains the tool, because it's the tool that depends on golang.org/x/tools. Based on what you showed in the linked issue, I guess that means that the dependency from packer-plugin-sdk is the one that needs to be updated here, because that seems to be the module which contains this "mapstructure-to-hcl2" tool.

@apparentlymart apparentlymart closed this as not planned Won't fix, can't repro, duplicate, stale Sep 2, 2022
thomasklein94 added a commit to thomasklein94/packer-plugin-libvirt that referenced this issue Nov 27, 2022
Newer go-cty version breaks `mapstructure-to-hcl2` tool, breaking the
build pipeline in the process. The current recommendation is to fall
back on older go-cty version.

See:
- hashicorp/packer-plugin-sdk#128
- zclconf/go-cty#132 (comment)
- zclconf/go-cty#134 (comment)

Revert "build(deps): bump github.com/zclconf/go-cty from 1.10.0 to 1.12.1"
Revert "build(deps): bump github.com/hashicorp/hcl/v2 from 2.14.1 to 2.15.0"

This reverts commit 4bc5b3e.
and commit 16bf32b.
sue445 added a commit to sue445/packer-provisioner-serverspec that referenced this issue Feb 11, 2023
Because the following error occurs when executing `go generate ./serverspec/...`

```
$ go generate ./serverspec/...
mapstructure-to-hcl2: serverspec.[Config]: Unexpected package creation during export data loading
serverspec/provisioner.go:1: running "packer-sdc": exit status 1
```

c.f.
* zclconf/go-cty#132
* thomasklein94/packer-plugin-libvirt@15dc54b
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

2 participants