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

Rerunning go-licenses now breaks when using --force and already have an output dir #91

Closed
n3wscott opened this issue Dec 16, 2021 · 6 comments · Fixed by #99
Closed
Assignees

Comments

@n3wscott
Copy link

This PR has introduced a bug where when you run the tool on an existing repo with the output directory in the project being scanned, https://github.com/google/go-licenses/pull/90/files#diff-63d2514e96da76ad8bd5c2460f4ea67c0a6c6ba1055a8890b7ec0c686bcc183fR70 finds all the previous license, which then are not locatable after https://github.com/google/go-licenses/pull/90/files#diff-63d2514e96da76ad8bd5c2460f4ea67c0a6c6ba1055a8890b7ec0c686bcc183fR76 if you use the tool with the the --force flag in play.

Originally posted by @n3wscott in #90 (comment)

@wlynch
Copy link
Contributor

wlynch commented Dec 21, 2021

Thanks for filing this! Can you provide a bit more details for how to reproduce this (e.g. args used, expected result, etc)?

My default stance is to roll this change back if it's causing problems, but I need some help reproducing the issue. 🙏

@wlynch wlynch self-assigned this Dec 21, 2021
@n3wscott
Copy link
Author

Howdy! sorry long delay, holidays...

Here is a little script you can run to see what I am seeing:

pushd $(mktemp -d)

go install github.com/google/go-licenses@master

go mod init example.com/demo

curl https://www.apache.org/licenses/LICENSE-2.0.txt > LICENSE

cat <<EOF > main.go
package main
import (
  . "github.com/hashicorp/golang-lru"
)
func main() {
  New(128)
}
EOF

go mod tidy

go mod vendor

git init

git add .

git commit -m "after vendor"

go-licenses save ./... --save_path="third_party/VENDOR-LICENSE" --force

git add .

git commit -m "after first licesnse save"

go mod vendor

go-licenses save ./... --save_path="third_party/VENDOR-LICENSE" --force

@n3wscott
Copy link
Author

n3wscott commented Dec 29, 2021

The error I get locally:

Error: open /var/folders/65/kbdvw9617tx1x8qh8f6md2xw0000gn/T/tmp.yWaWgyJ1/third_party/VENDOR-LICENSE/github.com/hashicorp/golang-lru/LICENSE: no such file or directory
Usage:
  licenses save <package> [flags]

Flags:
      --force              Delete the destination directory if it already exists.
  -h, --help               help for save
      --save_path string   Directory into which files should be saved that are required by license terms

Global Flags:
      --alsologtostderr                  log to standard error as well as files
      --confidence_threshold float       Minimum confidence required in order to positively identify a license. (default 0.9)
      --log_backtrace_at traceLocation   when logging hits line file:N, emit a stack trace (default :0)
      --log_dir string                   If non-empty, write log files in this directory
      --logtostderr                      log to standard error instead of files
      --stderrthreshold severity         logs at or above this threshold go to stderr (default 2)
  -v, --v Level                          log level for V logs
      --vmodule moduleSpec               comma-separated list of pattern=N settings for file-filtered logging

F1229 12:15:02.542070   57909 main.go:43] open /var/folders/65/kbdvw9617tx1x8qh8f6md2xw0000gn/T/tmp.yWaWgyJ1/third_party/VENDOR-LICENSE/github.com/hashicorp/golang-lru/LICENSE: no such file or directory
¯\(°_o)/¯ tree
.
├── LICENSE
├── go.mod
├── go.sum
├── main.go
├── third_party
└── vendor
    ├── github.com
    │   └── hashicorp
    │       └── golang-lru
    │           ├── 2q.go
    │           ├── LICENSE
    │           ├── README.md
    │           ├── arc.go
    │           ├── doc.go
    │           ├── lru.go
    │           └── simplelru
    │               ├── lru.go
    │               └── lru_interface.go
    └── modules.txt

6 directories, 13 files

@n3wscott
Copy link
Author

I think this error is the LICENSE file inside third_party has been indexed, but then it was deleted and then attempted to be accessed.

@benmoss
Copy link

benmoss commented Jan 11, 2022

I think part of the problem is that the third_party dir is getting treated as packages to be licensified:

❯ go list ./...
example.com/demo
example.com/demo/third_party/VENDOR-LICENSE/github.com/hashicorp/golang-lru
example.com/demo/third_party/VENDOR-LICENSE/github.com/hashicorp/golang-lru/simplelru

@wlynch
Copy link
Contributor

wlynch commented Jan 11, 2022

Approved #99 to roll back this change. Sorry about the trouble!

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

Successfully merging a pull request may close this issue.

3 participants