LicenseFinder icon indicating copy to clipboard operation
LicenseFinder copied to clipboard

Error on simple go project: invalid go version '1.23.1'

Open bichselb opened this issue 1 year ago • 0 comments

Running LicenseFinder on the simplest possible go project yields the following error for me:

GO111MODULE=on go list -mod=readonly -deps -f '{{ if and (.DepOnly) (.Module) (not .Standard) }}{{ $mod := (or .Module.Replace .Module) }}{{ $mod.Path }},{{ $mod.Version }},{{ or $mod.Dir .Dir }}{{ end }}' ./...: did not succeed.
GO111MODULE=on go list -mod=readonly -deps -f '{{ if and (.DepOnly) (.Module) (not .Standard) }}{{ $mod := (or .Module.Replace .Module) }}{{ $mod.Path }},{{ $mod.Version }},{{ or $mod.Dir .Dir }}{{ end }}' ./...: Getting the dependencies from go list failed 
        go: errors parsing go.mod:
/scan/go.mod:3: invalid go version '1.23.1': must match format 1.23

If I manually edit go.mod to use go 1.23 instead of go 1.23.1, then I get the following error instead:

GO111MODULE=on go list -mod=readonly -deps -f '{{ if and (.DepOnly) (.Module) (not .Standard) }}{{ $mod := (or .Module.Replace .Module) }}{{ $mod.Path }},{{ $mod.Version }},{{ or $mod.Dir .Dir }}{{ end }}' ./...: did not succeed.
GO111MODULE=on go list -mod=readonly -deps -f '{{ if and (.DepOnly) (.Module) (not .Standard) }}{{ $mod := (or .Module.Replace .Module) }}{{ $mod.Path }},{{ $mod.Version }},{{ or $mod.Dir .Dir }}{{ end }}' ./...: Getting the dependencies from go list failed 
        go: downloading gonum.org/v1/gonum v0.15.1
/gopath/pkg/mod/gonum.org/v1/[email protected]/floats/floats.go:10:2: package slices is not in GOROOT (/go/src/slices)

Context

Here is exactly what I tried:

#!/bin/bash

##################
# LICENSE FINDER #
##################

rm -rf LicenseFinder

echo "Cloning LicenseFinder..."
git clone https://github.com/pivotal/LicenseFinder
cd LicenseFinder && git checkout v7.2.1 && cd ..

##############
# GO PROJECT #
##############

PROJECT_NAME="simple-go-project"

# Clean up any previous project
rm -rf "$PROJECT_NAME"
mkdir -p "$PROJECT_NAME"
cd "$PROJECT_NAME"

# Display Go version
go version

# Initialize Go module
go mod init "$PROJECT_NAME"

# Add Gonum as a dependency
go get gonum.org/v1/gonum

# Create a main.go file with the Gonum dependency
cat <<EOF > main.go
package main

import (
    "fmt"
    "gonum.org/v1/gonum/mat"
)

func main() {
    // Create a 2x2 matrix
    a := mat.NewDense(2, 2, []float64{1, 2, 3, 4})
    
    // Display the matrix
    fc := mat.Formatted(a, mat.Prefix("          "), mat.Squeeze())
    fmt.Printf("Matrix A:\n%v\n", fc)
}
EOF

# Run the Go application
go run main.go

#################
# FIND LICENSES #
#################

../LicenseFinder/dlf license_finder report --format markdown

Here is the full output:

Cloning LicenseFinder...
Cloning into 'LicenseFinder'...
Note: switching to 'v7.2.1'.

You are in 'detached HEAD' state. You can look around, make experimental
changes and commit them, and you can discard any commits you make in this
state without impacting any branches by switching back to a branch.

If you want to create a new branch to retain commits you create, you may
do so (now or later) by using -c with the switch command. Example:

  git switch -c <new-branch-name>

Or undo this operation with:

  git switch -

Turn off this advice by setting config variable advice.detachedHead to false

HEAD is now at 00b04cb9 Update changelog for version: 7.2.1
go version go1.23.1 linux/amd64
go: creating new go.mod: module simple-go-project
go: added gonum.org/v1/gonum v0.15.1
Matrix A:
⎡1  2⎤
          ⎣3  4⎦
LicenseFinder::GoModules: [32mis active for '/scan'[0m
GO111MODULE=on go list -mod=readonly -deps -f '{{ if and (.DepOnly) (.Module) (not .Standard) }}{{ $mod := (or .Module.Replace .Module) }}{{ $mod.Path }},{{ $mod.Version }},{{ or $mod.Dir .Dir }}{{ end }}' ./...: [31mdid not succeed.[0m
GO111MODULE=on go list -mod=readonly -deps -f '{{ if and (.DepOnly) (.Module) (not .Standard) }}{{ $mod := (or .Module.Replace .Module) }}{{ $mod.Path }},{{ $mod.Version }},{{ or $mod.Dir .Dir }}{{ end }}' ./...: [31mGetting the dependencies from go list failed 
	go: errors parsing go.mod:
/scan/go.mod:3: invalid go version '1.23.1': must match format 1.23
[0m
/usr/share/rvm/gems/ruby-3.2.3/gems/license_finder-7.2.1/lib/license_finder/package_managers/go_modules.rb:63:in `block in packages_info': [1mCommand 'GO111MODULE=on go list -mod=readonly -deps -f '{{ if and (.DepOnly) (.Module) (not .Standard) }}{{ $mod := (or .Module.Replace .Module) }}{{ $mod.Path }},{{ $mod.Version }},{{ or $mod.Dir .Dir }}{{ end }}' ./...' failed to execute ([1;4mRuntimeError[m[1m)[m
	from /usr/share/rvm/gems/ruby-3.2.3/gems/license_finder-7.2.1/lib/license_finder/package_managers/go_modules.rb:32:in `chdir'
	from /usr/share/rvm/gems/ruby-3.2.3/gems/license_finder-7.2.1/lib/license_finder/package_managers/go_modules.rb:32:in `packages_info'
	from /usr/share/rvm/gems/ruby-3.2.3/gems/license_finder-7.2.1/lib/license_finder/package_managers/go_modules.rb:20:in `current_packages'
	from /usr/share/rvm/gems/ruby-3.2.3/gems/license_finder-7.2.1/lib/license_finder/package_manager.rb:105:in `current_packages_with_relations'
	from /usr/share/rvm/gems/ruby-3.2.3/gems/license_finder-7.2.1/lib/license_finder/scanner.rb:42:in `each'
	from /usr/share/rvm/gems/ruby-3.2.3/gems/license_finder-7.2.1/lib/license_finder/scanner.rb:42:in `flat_map'
	from /usr/share/rvm/gems/ruby-3.2.3/gems/license_finder-7.2.1/lib/license_finder/scanner.rb:42:in `active_packages'
	from /usr/share/rvm/gems/ruby-3.2.3/gems/license_finder-7.2.1/lib/license_finder/core.rb:84:in `current_packages'
	from /usr/share/rvm/gems/ruby-3.2.3/gems/license_finder-7.2.1/lib/license_finder/core.rb:79:in `decision_applier'
	from /usr/share/rvm/rubies/ruby-3.2.3/lib/ruby/3.2.0/forwardable.rb:234:in `acknowledged'
	from /usr/share/rvm/gems/ruby-3.2.3/gems/license_finder-7.2.1/lib/license_finder/license_aggregator.rb:51:in `block in aggregate_packages'
	from /usr/share/rvm/gems/ruby-3.2.3/gems/license_finder-7.2.1/lib/license_finder/license_aggregator.rb:49:in `each'
	from /usr/share/rvm/gems/ruby-3.2.3/gems/license_finder-7.2.1/lib/license_finder/license_aggregator.rb:49:in `flat_map'
	from /usr/share/rvm/gems/ruby-3.2.3/gems/license_finder-7.2.1/lib/license_finder/license_aggregator.rb:49:in `aggregate_packages'
	from /usr/share/rvm/gems/ruby-3.2.3/gems/license_finder-7.2.1/lib/license_finder/license_aggregator.rb:11:in `dependencies'
	from /usr/share/rvm/gems/ruby-3.2.3/gems/license_finder-7.2.1/lib/license_finder/cli/main.rb:161:in `report'
	from /usr/share/rvm/gems/ruby-3.2.3/gems/thor-1.3.1/lib/thor/command.rb:28:in `run'
	from /usr/share/rvm/gems/ruby-3.2.3/gems/thor-1.3.1/lib/thor/invocation.rb:127:in `invoke_command'
	from /usr/share/rvm/gems/ruby-3.2.3/gems/thor-1.3.1/lib/thor.rb:527:in `dispatch'
	from /usr/share/rvm/gems/ruby-3.2.3/gems/thor-1.3.1/lib/thor/base.rb:584:in `start'
	from /usr/share/rvm/gems/ruby-3.2.3/gems/license_finder-7.2.1/bin/license_finder:6:in `<top (required)>'
	from /usr/share/rvm/gems/ruby-3.2.3/bin/license_finder:25:in `load'
	from /usr/share/rvm/gems/ruby-3.2.3/bin/license_finder:25:in `<main>'
	from /usr/share/rvm/gems/ruby-3.2.3/bin/ruby_executable_hooks:22:in `eval'
	from /usr/share/rvm/gems/ruby-3.2.3/bin/ruby_executable_hooks:22:in `<main>'

bichselb avatar Nov 04 '24 12:11 bichselb