-
Notifications
You must be signed in to change notification settings - Fork 1k
Vendor pruning #120
Comments
This is news to to me. How do you plan to support checking in deps for those who want this? |
In govendor a popular approach has been to specify build tags to ignore. If you don't have any ignore build tags then you can keep the repo as is for those who wants that. It also serves to ignore appengine special files or other unsupported platforms. |
Yeah, this is a newish thing. It's something we discussed within the committee, but I'm making it explicit here after discussions with @rsc .
I have another draft issue I'm working on where we can explore that. Hopefully I'll get it up today. |
Yeah, that makes a ton of sense, and I think it's complementary to the other approaches. I'm now reminded that @freeformz has definitely brought this up in past discussions, too. Updating the original issue to include this... |
|
It would, I don't think that level (os/arch tags) of pruning should be on by default, but pruning of unused packages should. |
@jessfraz I couldn’t agree more ... |
@olekukonko for sure, and that's what that's intended to mean - if we add such a feature, then the user could choose to enable pruning out dependencies entailed solely by a particular build tag. To be clear, though, this would only affect the deps that actually get written out to |
So speaking of pruning.. 1 concern that I hit while trying to vendor kops out as a library (I know I am crazy.. don't ask..) The project used go-bindata to generate a file that was clobbered by vendoring... It was a fairly big deal that the file was in the vendor directory to use the tool as a library.. Not advocating that this is necessarily a good idea/design by any means.. Mostly sharing a real experience from the wild that might come up later.. especially if we start pulling files out of Thoughts? |
@kris-nova oh, this is a great question! Though...i actually can't quite picture the exact workflow you're describing with this:
i think the answer depends considerably on the details. Could you be a little more specific about how this worked, what "the project" refers to (your attempt to vendor kops, or some dep that kops had with this weird requirement), where these generated files were, etc.? |
Ah sorry, so here are the steps that I observed: Basically there was a When using kops as a dependency, we could generate the file and it would live appropriately in
An remembered my experience with losing the file.. so I figured I would call it out.. ..on second glance it looks like there is discussion around manifests that could prevent this happening..
so this point very well could be moot 😄 |
Speaking of pruning unnecessary files, a while ago I was hit by annoying issues with dependency managers (specifically GB) that blindly trim everything except *.go files: there is a high change you wipe out files used by So far, I encountered only an handful of packages that were affected by the strict trimming, therefor it's not really a high priority issue and I solved it by manually copying the missing files when necessary. The real problem here isn't the manual copy per se, but the fact that a strict trimming could break automatic deployment pipelines too — such as Heroku's tools and a-like. You can't fix an automatic deployment pipeline by manually copy the missing files (it's an oxymoron), especially if you don't have any control over the library/package that breaks. It would be nice for golang/dep to not fall into the "trim everything except *.go files" trap.
Pruning unnecessary files is a nice idea, in theory. Especially if you want to guarantee reproducible compilations (which I care a lot about), so ideally an optional feature is the only viable solution at the moment — at least until there is a reasonable heuristic about what can be safely pruned and what not. When the pruning breaks stuff, let the user disable the pruning (doesn't matter if by CLI or by editing a conf file, provided the behaviour is documented). ¹- |
@Dr-Terrible govendor normally only copies *.go files and README / LICENSE style files. However you can also specify grab everything in the repo. I think normal trimming is important. I also think being able to grab everything is an important out. Concrete uses are C interop and out of file resources (html for a web site). |
IMHO, I think that what LK4D4/vndr cleans up is good enough, especially the pruning of |
Maybe the manifest could have an option for telling what prunning policy do you want and by default just copies TL;DR: IMHO, copying README/LICENSE/etc and all files that can be go or cgo source code (excluding tests) it's what I think should be on by default. Any other (reasonable) case should be possible to handle but in an opt-in way. |
I'm pretty certain it's the right thing to do to have the pruning policy set in the current project's manifest; otherwise, there's no way of knowing which subset of files to hash (assuming we do a subset). Plus, teams that commit I'm less sure about having each dependent project's manifest specify its own policy, though. For one, when I set the policy for my own project, my needs may be different than my dependees - different os/arch, and they probably don't need my tests. So, it might be useful to bubble policy suggestions up from deps' manifests to help the user set a policy in their own manifest, but I think directly reusing them might not work out well. It depends a lot on what constitutes a "policy." (BTW, side note: the distinction between the powers afforded to the current/root project's manifest, vs. a dependent project's manifest, is encoded in gps.RootManifest vs. gps.Manifest). |
Hi, First of all, I would like to start by saying that I'm baffled by this note:
We don't have a tool that works good, out of the box with the current solution but we already deprecate the one that we are building... It's unfortunate and confusing to say the least. Now, back on track to my issue. I've described this in Slack but here's the description of the issue again. My colleague was using one of the popular vendoring tools. That said tool decided stripped out unused packages / files from the packages. Now that my colleague needed to use the said part of the missing dependency he was: "but why do I need to update my dependencies? I've already said it to vendor this package and all packages it contains". From what I can see the upcoming tool will continue with this bad UX. Why is it a bad UX? Because people really expect a thing from a package manager that's very basic: copy the package contents from remote to vendor/ by default. If they either it needs a flag or reruns to have this functionality then the issue is revealed. As such, I would highly vote/recommend/voice/shout/add opinion/etc. that the Package Manager should not do anything smart unless so instructed by the user. The user has to be in control on how this works because then the user can replicate this in any environment the tool will be used, be it a team of one or or a team of 500. In ending of this, I would like to share a talk which made me rethink the way I approach problems when it comes to UX: https://www.youtube.com/watch?v=5tg1ONG18H8 I hope it will be of help as well. |
The entire purpose of this issue is to discuss what is safe to do, starting with some structured possible suggestions. If your perception of the proposal is that it's already decided we're doing all these things, then I'd encourage you to reread the proposal. In particular, this line:
Maybe that latter half isn't explicit enough: my own guideline is that safety comes first. Personally, I'm becoming less and less inclined towards pruning at all because of the annoyances it creates for verification.
I'm not sure that's the case (but I am sure that's an assertion absent evidence). For other package managers (in other langs) that include, say, build/codegen steps, the expectations are more complex than "just copying."
I addressed this in my comment immediately before yours: #120 (comment)
Also, I find your objection here surprising, given that the impulse to minimize the contents of |
Could e.g.
https://github.com/coreos/etcd/blob/master/scripts/updatedep.sh We are evaluating Is there any large project using |
Analyze packages in deterministic order when generating hash
As @gyuho mentioned, I also think that From my understanding, however, What's a better approach? Directly add those options to the current form of |
+1, and other non-go files.
hmmm, I don't know about this. ~Most licenses (ie Apache 2.0, which covers lots of my world right now) need you to redistribute the license, and I wouldn't want to try and guess which licenses are safe to remove TBH.
@sdboyer whats you're current thinking on this? I'm personally keen to see this stay as part of the I'd like to see it rolled into |
Ugh. I'm still pretty torn between the different guarantees I'd like us to be able to provide. But this really can't/oughtn't wait much longer, so lemme try to take a stab. Here's me, thinking through it in bullets:
I think that basic approach should more or less satisfy these competing requirements. It should allow us to have verifiable vendor dirs, while still having automatic pruning within The catch will be that it won't be possible to verify a more-than-default pruned I realize this sketch is basically me drawing dots and leaving you to connect them - sorry 😄 i don't have time for a more detailed writeup just now. But it's a tentative "yes" to making pruning work as an automated part of |
@sdboyer You may be interested in govendor smarter tag ignoring logic: https://github.com/kardianos/govendor/blob/master/context/tags_test.go I could contribute to dep if you'd like. |
@kardianos oh oh oh interesting! yesyes, that work looks like the shape of what we'll ultimately need for #291. i'd be absolutely thrilled if we could incorporate what you've already done. that area is a bit particular, and i've not fully absorbed what you've written there, but this: // However in govendor all questions are reversed. Rather then asking
// "What should be built?" we ask "What should be ingored?". strongly suggests that we're in the right ballpark. |
Does this mean we'll have the default CLI arguments only for the
Or what's your thinking here? |
For anyone interested, I'm using the following .gitignore rules to filter out unnecessary files:
|
I don't really see a need for flags at all - why add the complexity to |
@sdboyer sounds good, as long as |
@VojtechVitek should those settings for Gopkg.toml be working with a dep from current master? |
@wedgeV sadly no, those are just a proposal. we still need someone to implement the guts, here. |
Closed in favor of #944 |
NB: keep in mind that the we see
vendor/
as a temporary solution, and expect to eventually move to some newer, better version of GOPATH that largely obviates the need for it.Currently, dep naively copies dependent repositories into
vendor/
in their entirety. This may produce avendor/
directory with a lot of unnecessary files, and many projects relying on existing community tools use some technique to prune out unneeded files.It is unlikely that we could develop a pruning solution that would be as aggressive as every user wants, while still being safe for all other users. However, we would like to establish baseline pruning behavior that is safe for everyone, so that dep can perform it unconditionally, or with a minimum of necessary user input. If nothing else, this has performance benefits: if dep does the pruning, then it's possible for us to implement optimizations to simply avoid copying files that would later be removed.
There are a few, not fully orthogonal, classes of pruning we might consider:
vendor/
directories. This is required for correct builds, and dep will always do it.lock.json
- only whether they're pruned fromvendor
.)import
ed by code, orrequire
d in the manifest), and could selectively remove those that are not needed. There are sub-considerations here:ignore
d in the manifest be pruning or preserved?.go
files? What types of files?There's some debate as to whether removing files may be a violation of some software licenses. Getting clarity on this question would be ideal; if we can't, then we'll likely have to make additional pruning behaviors optional in order to avoid having dep blacklisted by legal departments.
Finally, pruning is intimately linked to how we approach the problem of vendor verification (#121).
Note that the logic for writing out the dependency tree lives in gps, and is likely to remain there. This issue is to discuss what the behavior and options should be; implementation will happen over there.
The text was updated successfully, but these errors were encountered: