shurcooL / binstale

binstale tells you whether the binaries in your GOPATH/bin are stale or up to date.
MIT License
146 stars 4 forks source link

option to ignore binaries under /vendor/ paths? #5

Closed klauern closed 8 years ago

klauern commented 8 years ago

When I run binstale, I find that all of my binaries are up-to-date, but that many of the projects' vendor directories are not. Is there a way to ignore any of the /vendor paths, or make that a default? For instance:

gorename
        STALE: github.com/visualfc/gotools/vendor/golang.org/x/tools/cmd/gorename
        up to date: golang.org/x/tools/cmd/gorename
...
fuzz
        up to date: github.com/gorilla/securecookie/fuzz
        STALE: github.com/klauern/envoy-web/vendor/github.com/gorilla/securecookie/fuzz
...
eg
        STALE: github.com/visualfc/gotools/vendor/golang.org/x/tools/cmd/eg
        up to date: golang.org/x/tools/cmd/eg

etc.

dmitshur commented 8 years ago

Hmm, that does look suboptimal.

It looks like you would want to filter out commands in vendor from output of binstale in most cases, but what if someone actually has a command they've installed from a vendor directory?

I'm a little surprised that there any commands in vendor directories - what's the point of vendoring those? Isn't /vendor/ usually for libraries that are imported?

I'd rather avoid having to add a flag unless there's absolutely no better way of dealing with this.

I've also realized something. It appears that a common way of dealing with vendored packages getting in the way when doing go generate ./... or go test ./..., which is appending | grep -v /vendor/ will work here too. Maybe that's this should be dealt with. What do you think?

$ binstale | grep -v /vendor/
gorename
        up to date: golang.org/x/tools/cmd/gorename
...
fuzz
        up to date: github.com/gorilla/securecookie/fuzz
...
eg
        up to date: golang.org/x/tools/cmd/eg
klauern commented 8 years ago

I could do that, but as I am running on Win7, piping to grep isn't necessarily a workable option.

dmitshur commented 8 years ago

Hmm, that's unfortunate.

When I used Go on Windows, I had some mingw thing that I got as part of installing git on Windows. I'm pretty sure it has grep and other unix tools. Could you use that?

Also, Ubuntu and linux terminal is coming to Windows, maybe that can help?

Do you have any ideas for how to do better?

klauern commented 8 years ago

i'll see what I can do. I have MinGW, but it's hit or miss if some commands work properly in Powershell, where I'm running these commands.

I would love to try out the Bash on Ubuntu on Windows thing, but I'm not sure that's possible, either, at least from my corporate environment's pace of upgrading.

If it's safe to say that binstale won't be able to ignore the vendor/ directories, I'll look into scripting out a filter somehow on my end.

dmitshur commented 8 years ago

If it's safe to say that binstale won't be able to ignore the vendor/ directories,

It's not safe to say that, I welcome ideas for how binstale can do that in a general and reliable way. I just don't have any good ones.

Right now, the only way I can think of is by adding some flag, but I'd be really hesitant to do that because I think this problem should be solved in a similar way to how the go tool deals with it (with is currently by expecting user to deal with it). If there's some other way, I welcome suggestions and I'm happy to see if it would meet all the criteria.

klauern commented 8 years ago

I think I found something that's workable on my end.

binstale | awk '{ if (($1 ~ /STALE/) && ($2 !~ /vendor/)) print $2 }' | echo

I do have awk installed, so for whatever reason, that seems to work. I'll take it, though. :)

dmitshur commented 8 years ago

Sorry about the inconvenience, it's unfortunate we can't think of a better general solution for this. But I place blame on how /vendor/ was rolled out, and potentially on the vendoring tool. Which vendoring tool was it? Looking at github.com/visualfc/gotools, it seems they use git submodules inside /vendor/, that's why all commands are included. I can't access github.com/klauern/envoy-web so I assume it's a private repo.

I'm glad you found something that does work, and for sharing it here so I can point other Windows users in same situation to it.

If you feel like raising this issue, I suggest bringing it up at the Go project in some (respectful) way. If problems are not visible, they're unlikely to be fixed. And I don't think they should be covered up by each tool built on top of the Go ecosystem.

I'll close since you've said it works for you, and there's nothing more I can do here. Let me know if anything else comes up.

klauern commented 8 years ago

Thank you for looking into this and pointing that out. I am a hobbyist for Go, so these kinds of issues do make it difficult to remain productive with the little freetime available, but the challenges to solve are certainly easier to overcome than other platforms, tools, and frameworks I've used. It's certainly a lot easier to smash some command-line calls together than to try to define something akin to a Maven plugin or something.

Thank you again