-
Notifications
You must be signed in to change notification settings - Fork 540
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
Checking in the vendor folder in Git #112
Comments
Can you give the particular error? We've been chatting about this for a while. Since Glide keeps the repos as they are, if you try to check in the vendor folder, Git will treat this as a submodule (is that right, @mattfarina ?), which gets weird. We've talked about a few solutions, but nothing has emerged as particularly easy for users. So if you have some ideas, we'd be happy to hear. We're re-working pinning to make that easier to do, and the big commit that happened today switched from nested vendor folders to a flatter architecture (because nesting causes some bad behaviors). The 0.7 version will be a pretty big change. |
I'll play a little bit with it in order to provide more details. My first impression is that treating it as submodule is a great approach but don't know what the side effects or complications it brings. I cannot classify it as an error, it was just that I initialized a glide project, added some dependencies, commited the changes (including the vendor folder), then a co-worker cloned it and when he tried to But, again, I'll play with it a little bit more and provide better detail. I just wanted to know if I was missing some steps or if that was already expected/known behavior. Thanks! |
I think the issues are are with the git submodule workflow. I typically suggest two different workflows.
Going down the submodule route will bring in the submodule commands. I'm not entirely sure the best way to do that since I don't use submodules. That's the referenced stuff, as I'm reading it, from the original issue description. Does that help? I know I'm not answering your exact question. I'm not sure the best way to use submodules. |
best way to use submodules: don't use submodules. no, but really. there's almost nothing you can't accomplish with subtrees, and submodules are so fraught with traps, unexpected behaviors, necessary workflow changes...there is a small, almost negligible subset of workflows and use cases for which they are appropriate, but including them into a general purpose tool like glide is a recipe for heartache. here's a pretty nice, fairly recent overview. |
Based on @mattfarina's comment and reading the article @sdboyer shared:
So if Will submodules continue being the preferred road? |
yeah, that line stuck out to me too - i actually had the feeling that i should note it in responding here. here's a slightly less glib breakdown (sorry, i was tired last night). because submodules track an immutable commit, not mutable ref (branch or tag), they never move unless you explicitly tell them to. and when you tell them to, that's actually a change in the parent repository. what the parent repository tracks is actually a special, git-only filetype object, as evidenced by the diff when you add a submodule: diff --git a/testrepo b/testrepo
new file mode 160000
index 0000000..4d59fb5
--- /dev/null
+++ b/testrepo
@@ -0,0 +1 @@
+Subproject commit 4d59fb584b15a94d7401e356d2875c472d76ef45 the file's "contents" are that string. and that file is of a special, different type, as indicated by
i point this out just to say that "there be magic here." the primary purpose of that magic is to allow git to manage multiple discrete repositories together in a lockstep, controlled way. in fact, the case it's really designed for is managing external, vendor dependencies - they don't update often, and when they are, it's a significant event that should be reflected by a commit in the main repository. that should sound familiar - it's a subset of the responsibility of a tool like glide (or npm, or composer, or bundler, or cargo, or...). which is actually an argument AGAINST their use here. git submodules try to be a general solution to the problem of vendoring, but operate with fewer constraints AND less information than modern package mgmt tooling. they have their own manifests ( all of this is to say that, unlike many other parts of git, submodules should not be looked at as just another piece of git plumbing that can effectively act as a library to deliver the functionality you want in your tool. they're a standalone thing, and if you've already got your own manifests (which glide does), then they fundamentally don't offer anything except an integration headache. |
@fervic if you use glide to track your version (reference or in the near future semantic version) than I would not use submodules. Instead let glide manager your version. I would be wary of checking in
In the above structure the package The way Go searches for the right If all the projects check in their dependencies to the If you do choose to check dependencies in I would suggest removing the VCS (e.g., Does that help? |
@mattfarina yes that helps, thanks! But the thing is, in a normal workflow, Glide will use GIT submodules by default, that's what happened to me. And the Let me explain what I did (this is all using v0.6.1): I had an existing project, so I went into its root folder and issued the following commands:
Then:
In my repo (local) it downloaded all files from external packages, but on the remote (Github), it pushed the following files: Where each is a text file with the commit hash (as this is how Git manages submodules) I see this as the current default behavior of Glide, so I don't know if the README should have some of this stated more clearly or if Regards! P.S. I can help contributing with code, but wouldn't want to go unaligned with your ideas. For example what about @sdboyer's suggestion of not using submodules? He makes a good point about that Glide shouldn't rely on it for delivering certain functionality. |
I see where you're coming from now. There's a difference between theory and practice. Let me explain and possibly provide a path forward. Glide is doing this for you because you're using Git. Glide works with git, svn, bzr, and hg. It's not tightly coupled to git but works with it. So, in theory it's up to the user to manage their Glide doesn't rely on submodules. Instead it's like composer or npm in that storing the packages or not is left as an exercise for the end user. In practice there are cases where things like this can happen that aren't entirely clear. Given the VCS agnostic nature of Glide, how would you suggest conveying some good practices? There is a section in the FAQ about checking the Note, pinning to a commit will become less necessary in the future. We're going to start supporting semantic versioning in the future. Thoughts? |
Just as a quick side note, I remember reading somewhere in Go documentation that they (Go authors) didn't want to impose any versioning system for packages (like semver). I like semver, but Glide would depend on the community that generates packages to use semver. So maybe sticking to a VCS reference is not such a bad choice. Regarding Git and submodules, please forgive my ignorance and misunderstanding, I thought you were using the submodule feature on purpose, now I see this behavior is just the result of basic nested git cloning and actually taking the submodule route is one of the approaches users could take. That said, my only thought is to do some small edits to the README, be a little more emphatic about why it is discouraged to check-in the Thanks again! |
@fervic there is a proposal for the Go community to adopt semver. Before moving forward they want some systems to implement semver. We already have gopkg.in but need more to move this forward. Some things already use it. Commit ids really aren't useful enough. If someone releases a security release or bug fix and you only have commit ids will you know if you have a version with that security release or bug fix? This is an issue for package maintainers on systems like Ubuntu (according to Dave Cheney). So, we are looking to help move this along. |
I too was frustrated by the default git submodule behavior. See this StackOverflow question for more context. Basically, I'm writing a library and wanted to check in the vendor directory so that users of the library would not necessarily need to install Glide. The goal is to get vendoring working with As far as I can tell, all the commands I want to run (e.g. EDIT: I spoke too soon. After completely removing the project locally, attempting to install again with |
@albrow keep us posted, please. I, too, have been frustrated that it seems like I'm pondering what it would take to build a remote service along the lines of What I'm imagining would be some service that could answer a |
@albrow Was the error something along the lines of Personally, I like the idea of using git submodules to track dependencies - it's basically just an association of "package = url + revision". A tool like glide could assist you with picking out the correct revision, whether by comparing semver, tracking a branch, etc, while restoring go-gettability (with the above caveats). |
First, this isn't about my opinion. More a matter of something we need to take into account for anything we craft.
This is from the Git documentation. Many find submodules to be difficult to work with and they can be a source of confusion. I learned this answering questions about submodules in the past. Anyone attempting to leverage them I would suggest paying attention to your audience to make sure they are a good solution. Again, I'm neither for or against them. More, I'm aware of the usability issues that can happen and how that affects a project. |
@mattfarina Shouldn't glide be removing the An option can be added for those who wish to experience the pain of submodules. |
For what it's worth, I tried out glide and found it to be a really awesome tool. Great work so far! However this is the single issue that's blocking me and my company from using it in all of our projects. Removing the .git stuff is all that should be needed for us. Seems like a trivial change, and we'd be happy to help with the change if the maintainers are ok with this direction. |
@stevvooe and @sym3tri A few things...
|
@mattfarina I understand the issue here. To clarify, our requirements for a dependency management system are somewhat like the following:
From some of what you've written, it seems How would this look? The project maintainer could setup glide to instruct it to remove glide init --remove-repository-directories The configuration file would have an option in the glide.yaml file: package: github.com/docker/swarm-v2
vendor:
repository_directories: remove
import:
- package: github.com/gogo/protobuf
subpackages:
- /gogoproto
... Then, This is probably not an ideal solution but I hope it helps to provided a little clarity. If you choose to take the project in another direction, I completely understand. |
I don't understand why this is an issue. Can't you just That way git won't add submodules. I believe the |
because:
FWIW, i've switched my position on this - vendor should always be committable, and SCM metadata shouldn't be left around. it's just not trivial to do. |
So I guess I can expand that |
@dnephin nooooo, no more bash pls :) |
@sdboyer I don't think that's true. The target SCM is always consistent for any given user, so the second I guess it would be nice to have this as a plugin, or a go binary, but it feels like it's not absolutely necessary that it's part of glide core, because it's pretty easy to implement externally. @LK4D4 at least it's just one line of bash that you only run when you add entirely new dependencies! if you're adding a single dependency, you can probably just do |
@dnephin that's a fair point. i'm kinda just swooping in dickishly right now, anyway. sorry :) really, i'm doing so because, while working on my writeup, my view has shifted to where I don't believe that any user choice or interaction is necessary here, at all. it just muddies the water. both the commit-deps and don't-commit-deps cases can work equally well, and transparently, using what i call the "sync-based" approach. you shouldn't HAVE to write that script. @mattfarina and i were maybe gonna chat about that today, but it didn't come together. hopefully tomorrow. we'll see where things land. |
If you need that find functionality on Windows it's easily added in powershell:
Might be a better way to write that (I'm still a bit inexperienced in PS) but it beats relying on a compatible unix find being installed. |
Anything that requires bash or powershell fails requirement 3 above:
While a little bit of @sdboyer I had a quick run through of your write up. It seems that your head is on straight. Just let us know which direction you intend to take |
@stevvooe thanks! i really do think glide has the potential to be best-in-class, across languages. It's exciting :) we'll certainly be public about whatever our plans are. |
Has a clear decision been made on this subject? Because it still exists right now. |
@tanji yes. Currently, you can either strip vcs dirs out of vendor or not, depending on the opts you pass ( |
Glide now:
Because of that I'm going to close this issue. If there are continued discussions please open a new issue and we can continue that conversation. Thanks for all the thoughts here. |
Hi there,
This is more like a question, not an issue...
I just started using glide and I noticed a couple of things:
So, when adding the changed files, Git reported the files inside the vendor folder that just contained the commit id. So I thought it was great because, first because it isn't that much of extra space and second if something breaks after somebody runs
glide up
because of a change in the version of a dependency, you're able to look in your commit history what was the commit id at which the dependency was the last time everything worked fine.But then I noticed that if the vendor folder already exists,
glide up
doesn't work well. So I may have to ignore the full folder.I don't know exactly why it doesn't work or what is it trying to do, I just know that after removing the folder everything worked fine.
So my question is ... can I make it work having an existing vendor folder that only contains references to the commit ids of the dependencies?
The text was updated successfully, but these errors were encountered: