Skip to content

enumer fails on Windows with internal error: package "..." without types for various stdlib packages #125

Description

@aaa2ppp

Description:

When using enumer v1.6.3 on Windows (Go 1.27.1), the tool fails with an internal error during code generation. The error message references a standard library package (e.g., errors, fmt, etc.), but the specific package varies – it seems to depend on what packages are imported in the file being processed.

Steps to reproduce:

  1. On a Windows machine, install enumer using:
    go install github.com/dmarkham/enumer@v1.6.3
    
  2. Create a Go file with an enum type and the //go:generate enumer directive, and import some standard packages (e.g., errors).
  3. Run go generate ./... in the project.

Actual behavior:

The command fails with an error like:

enumer: internal error: package "errors" without types was imported from "..."

If you work around it by avoiding that package, it may fail with another package (e.g., fmt), suggesting the issue is not package-specific.

Expected behavior:

enumer should generate the enum code without errors.

Environment:

  • OS: Windows 10/11 (tested on Windows 10)
  • Go version: go1.27.1 windows/amd64
  • enumer version: v1.6.3 (installed via go install)

Additional context:

The same command works correctly on Linux (Go v1.26) with the same version. The issue seems specific to Windows or Go v1.27 and likely stems from outdated indirect dependencies in the enumer module (especially golang.org/x/tools and golang.org/x/mod) that may have Windows-specific fixes in newer versions.

Workaround found:

I discovered that building enumer manually from the latest source with updated dependencies resolves the issue:

git clone https://github.com/dmarkham/enumer.git
cd enumer
go get -u ./...
go install

After this, enumer works fine on Windows. This suggests that updating the module's dependencies to their latest versions would likely fix the problem for all Windows users.

Would you consider updating the module's dependencies to the latest versions to address this issue? Or is there a deeper root cause you're aware of?

Thank you for maintaining enumer - it's a valuable tool.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions