CycloneDX / CycloneDX/cyclonedx-gomod

Failed to load stdlib module when executing cyclonedx-gomod

Open
#423 3 comments 0 reactions 0 assignees View on GitHub
Dominant language
Go
Stars
187
Forks
40
Avg merge
1d 7h
Merged PRs (30d)
14

Description

The issue I'm facing is that I have a CI with Go 1.21 that tries to generate the bom for an application that requires Go 1.22.
The error I get is the following:

```bash
~ cyclonedx-gomod app -verbose -json=true -main ./cmd/server
12:29AM DBG loading modules moduleDir=.
12:29AM DBG executing command cmd="/usr/local/go/bin/go list -deps -json ./cmd/cli/" dir=.
12:29AM DBG executing command cmd="/usr/local/go/bin/go env -json" dir=
12:29AM DBG loading module moduleDir=/Users/ecampolo/go/pkg/mod/golang.org/toolchain@v0.0.1-go1.22.0.darwin-arm64/src
12:29AM DBG executing command cmd="/usr/local/go/bin/go list -mod readonly -json -m" dir=/Users/ecampolo/go/pkg/mod/golang.org/toolchain@v0.0.1-go1.22.0.darwin-arm64/src
12:29AM ERR error="failed to load modules: failed to convert packages to modules: failed to load stdlib module: failed to load stdlib module: listing module failed: command `/usr/local/go/bin/go list -mod readonly -json -m` failed: exit status 1"
```

While I'm not sure if it's a bug, the following behavior presents frictions with respect to the new policy in which Go 1.21+ version try to compile newer versions.

My goal is not to have to update de go version every time a release occur since now Go 1.21 and later will not try to compile code that requires a newer version of Go but instead download the corresponding toolchain.

Contributor guide

Open the contributing guide

Research direction

The report names no source file or test entry point. Reproduce the failure with Go 1.21, a Go 1.22-dependent application, and `cyclonedx-gomod app -verbose -json=true -main ./cmd/server`; then trace stdlib module loading around the logged `go list -mod readonly -json -m` command. Done means this toolchain scenario is handled or its failure is clearly covered by a regression test.

Written by the indexing model from the issue text.

Assessment

Tech stack
go
Domain
cli, devtools
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.