Open arvenil opened 8 years ago
@arvenil I think I can answer your question. This is where vendor/
practices get confusing and I'm happy to take feedback here.
github.com/aws/aws-sdk-go
uses all those dependencies within its codebase. Now, it does have 2 dependencies in a vendor/
folder. Where things get difficult is that each vendor/
folder is a different location and the same dependency in two different vendor/
folders, even if the same version, cannot share instances of types and will be in the compiled binary each time. This can lead to build issues and binary bloat. So, the recommendation, which Glide does automatically, is to only have one vendor/
folder at the top level of an application. To flatten the dependencies. Do you have a suggestion on how to do this better? I'm happy to have a conversation on it. If you want to chat in realtime you can find me in the #masterminds
room on Freenode IRC.vendor
dir it's not going to fetch any dependencies, just vendor dir. However glide currently works differently, it doesn't care if vendor
dir is there, it will always scan everything for dependencies. I'm not saying behavior is wrong, I'm saying that either I don't understand doc or doc says it wrong.glide get github.com/z/somepackage
scans all subpackages for dependencies, while I not necessary might want it. Maybe I only want somepackage
package, not any other subpackage. I think this is somehow related to #166 #164 I would expect to be able glide get github.com/z/somepackage
or glide get github.com/z/somepackage/...
or glide get github.com/z/somepackage/subpackage
(and I also run right now into a problem when nvm, my fault)glide get
ended up in infinite dependency loop:/ but didn't figure out yet, why the hell:/
@arvenil We're currently working to make #1 and #3 better. Optimization can be hard.
@mattfarina Can we close now that the solution to #1 and #3 are merged onto master?
@arvenil If you feel like re-testing off of master, we'd appreciate any input. This new version should be much better at selectively importing what is necessary, not blindly importing everything.
Wow, indeed it works better, fetches way less dependencies. 31 vs 51. Good job guys!
I still however have this remaining question for 1. The how it works section states:
It then recursively walks through the downloaded packages looking for those with a glide.yaml file (or Godep, gb, or GPM config file) that don't already have a vendor directory and installing their dependencies to their vendor directories.
but
vendor
directory and now I'm not sure if the new version works like the doc says, so github.com/aws/aws-sdk-go
is not scanned at all for dependencies because it has a vendor
dir, or it is still scanned and the doc is misleading? and installing their dependencies to their vendor directories
is also false now? As glide installs dependencies to top level vendor
dir?I also found out one inconsistency with fetching dependencies that is related to my questions. I think code is the simplest way to explain this :)
glide get github.com/aws/aws-sdk-go
fetches only one dep... so it looks like it cares about vendor
dir and doesn't scan it for dependencies?
bash-3.2$ glide create
[INFO] Generating a YAML configuration file and guessing the dependencies
[INFO] Attempting to import from other package managers (use --skip-import to skip)
bash-3.2$ glide get github.com/aws/aws-sdk-go
[INFO] Preparing to install 1 package.
[INFO] Importing github.com/aws/aws-sdk-go
[INFO] Downloading dependencies. Please wait...
[INFO] Fetching updates for github.com/aws/aws-sdk-go.
[INFO] Resolving imports
[INFO] Downloading dependencies. Please wait...
[INFO] Fetching updates for github.com/aws/aws-sdk-go.
bash-3.2$ cat glide.lock
hash: f0e0abd12e6cf5a81e2863ad24fcafedae90eef238a1108ed41c6efaa6bff74f
updated: 2016-02-10T14:16:53.052542434Z
imports:
- name: github.com/aws/aws-sdk-go
version: 0d8e5fdff6a7f73e2c8b84c02330c3c030650b82
devImports: []
Now I'm trying to fetch dependency (github.com/uniplaces/osin-dynamodb
) that depends on github.com/aws/aws-sdk-go
(more precisely on github.com/aws/aws-sdk-go/service/dynamodb
)
bash-3.2$ rm glide.lock glide.yaml
bash-3.2$ glide create
[INFO] Generating a YAML configuration file and guessing the dependencies
[INFO] Attempting to import from other package managers (use --skip-import to skip)
bash-3.2$ glide get github.com/uniplaces/osin-dynamodb
[INFO] Preparing to install 1 package.
[INFO] Importing github.com/uniplaces/osin-dynamodb
[INFO] Downloading dependencies. Please wait...
[INFO] Fetching updates for github.com/uniplaces/osin-dynamodb.
[INFO] Resolving imports
[INFO] Fetching updates for github.com/RangelReale/osin.
[INFO] Fetching updates for github.com/aws/aws-sdk-go.
[INFO] Fetching updates for github.com/pborman/uuid.
[INFO] Fetching updates for github.com/go-ini/ini.
[INFO] Fetching updates for github.com/jmespath/go-jmespath.
[INFO] Downloading dependencies. Please wait...
[INFO] Fetching updates for github.com/uniplaces/osin-dynamodb.
bash-3.2$ cat glide.lock
hash: f9b467e54af5991537817e9f40ef526311e41a8b51dfae4527f5fd17c2fa06c5
updated: 2016-02-10T14:32:49.801943376Z
imports:
- name: github.com/aws/aws-sdk-go
version: 0d8e5fdff6a7f73e2c8b84c02330c3c030650b82
subpackages:
- aws
- service/dynamodb
- aws/awserr
- aws/credentials
- aws/awsutil
- aws/client
- aws/client/metadata
- aws/request
- private/protocol/jsonrpc
- private/signer/v4
- private/waiter
- private/protocol/json/jsonutil
- private/protocol/rest
- private/protocol
- name: github.com/go-ini/ini
version: 193d1ecb466bf97aae8b454a5cfc192941c64809
- name: github.com/jmespath/go-jmespath
version: 0b12d6b521d83fc7f755e7cfc1b1fbdd35a01a74
- name: github.com/pborman/uuid
version: 0f1a46960a86dcdf5dd30d3e6568a497a997909f
- name: github.com/RangelReale/osin
version: 2d8139c3efb5d19649fea4215969840122a39f8e
- name: github.com/uniplaces/osin-dynamodb
version: a96212a5fd9159d83d80ed956032204e238fe65e
devImports: []
Notice github.com/jmespath/go-jmespath
in dependencies. This is purely dependency of github.com/aws/aws-sdk-go
but why it shows if it's in github.com/aws/aws-sdk-go
vendor dir? Especially that glide get github.com/aws/aws-sdk-go
didn't fetch it. I'm just guessing that this is related to the fact that github.com/uniplaces/osin-dynamodb
is dependent on subpackage of github.com/aws/aws-sdk-go
and maybe so glide doesn't see a vendor
dir because he doesn't check parent dir (or in other words root package).
Below is a proof that vendor/github.com/aws/aws-sdk-go/vendor/github.com/jmespath/go-jmespath
is actually used, and that vendor/github.com/jmespath/go-jmespath
is unnecessary fetched (and unused) dependency.
bash-3.2$ ls vendor/github.com/jmespath/go-jmespath
LICENSE api_test.go compliance_test.go interpreter_test.go parser_test.go
Makefile astnodetype_string.go functions.go lexer.go toktype_string.go
README.md cmd fuzz lexer_test.go util.go
api.go compliance interpreter.go parser.go util_test.go
bash-3.2$ go build -v -x 2>&1 | grep --color go-jmespath
github.com/uniplaces/glide-vendor-test1/vendor/github.com/aws/aws-sdk-go/vendor/github.com/jmespath/go-jmespath
mkdir -p $WORK/github.com/uniplaces/glide-vendor-test1/vendor/github.com/aws/aws-sdk-go/vendor/github.com/jmespath/go-jmespath/_obj/
cd /Users/kamil/go/src/github.com/uniplaces/glide-vendor-test1/vendor/github.com/aws/aws-sdk-go/vendor/github.com/jmespath/go-jmespath
/Users/kamil/.gobrew/versions/1.5.3/pkg/tool/darwin_amd64/compile -o $WORK/github.com/uniplaces/glide-vendor-test1/vendor/github.com/aws/aws-sdk-go/vendor/github.com/jmespath/go-jmespath.a -trimpath $WORK -p github.com/uniplaces/glide-vendor-test1/vendor/github.com/aws/aws-sdk-go/vendor/github.com/jmespath/go-jmespath -complete -buildid 4da3618a1da31cc431aadbdc9ac0d7338d5167e6 -D _/Users/kamil/go/src/github.com/uniplaces/glide-vendor-test1/vendor/github.com/aws/aws-sdk-go/vendor/github.com/jmespath/go-jmespath -I $WORK -pack ./api.go ./astnodetype_string.go ./functions.go ./interpreter.go ./lexer.go ./parser.go ./toktype_string.go ./util.go
/Users/kamil/.gobrew/versions/1.5.3/pkg/tool/darwin_amd64/compile -o $WORK/github.com/uniplaces/glide-vendor-test1/vendor/github.com/aws/aws-sdk-go/aws/awsutil.a -trimpath $WORK -p github.com/uniplaces/glide-vendor-test1/vendor/github.com/aws/aws-sdk-go/aws/awsutil -complete -buildid 42944d3fe42c2f8d7884f09360a5cc68c0d11f05 -importmap github.com/jmespath/go-jmespath=github.com/uniplaces/glide-vendor-test1/vendor/github.com/aws/aws-sdk-go/vendor/github.com/jmespath/go-jmespath -D _/Users/kamil/go/src/github.com/uniplaces/glide-vendor-test1/vendor/github.com/aws/aws-sdk-go/aws/awsutil -I $WORK -I /Users/kamil/go/pkg/darwin_amd64 -pack ./copy.go ./equal.go ./path_value.go ./prettify.go ./string_value.go
bash-3.2$ rm -rf vendor/github.com/jmespath/go-jmespath
bash-3.2$ go build -v -x 2>&1 | grep --color go-jmespath
github.com/uniplaces/glide-vendor-test1/vendor/github.com/aws/aws-sdk-go/vendor/github.com/jmespath/go-jmespath
mkdir -p $WORK/github.com/uniplaces/glide-vendor-test1/vendor/github.com/aws/aws-sdk-go/vendor/github.com/jmespath/go-jmespath/_obj/
cd /Users/kamil/go/src/github.com/uniplaces/glide-vendor-test1/vendor/github.com/aws/aws-sdk-go/vendor/github.com/jmespath/go-jmespath
/Users/kamil/.gobrew/versions/1.5.3/pkg/tool/darwin_amd64/compile -o $WORK/github.com/uniplaces/glide-vendor-test1/vendor/github.com/aws/aws-sdk-go/vendor/github.com/jmespath/go-jmespath.a -trimpath $WORK -p github.com/uniplaces/glide-vendor-test1/vendor/github.com/aws/aws-sdk-go/vendor/github.com/jmespath/go-jmespath -complete -buildid 4da3618a1da31cc431aadbdc9ac0d7338d5167e6 -D _/Users/kamil/go/src/github.com/uniplaces/glide-vendor-test1/vendor/github.com/aws/aws-sdk-go/vendor/github.com/jmespath/go-jmespath -I $WORK -pack ./api.go ./astnodetype_string.go ./functions.go ./interpreter.go ./lexer.go ./parser.go ./toktype_string.go ./util.go
/Users/kamil/.gobrew/versions/1.5.3/pkg/tool/darwin_amd64/compile -o $WORK/github.com/uniplaces/glide-vendor-test1/vendor/github.com/aws/aws-sdk-go/aws/awsutil.a -trimpath $WORK -p github.com/uniplaces/glide-vendor-test1/vendor/github.com/aws/aws-sdk-go/aws/awsutil -complete -buildid 42944d3fe42c2f8d7884f09360a5cc68c0d11f05 -importmap github.com/jmespath/go-jmespath=github.com/uniplaces/glide-vendor-test1/vendor/github.com/aws/aws-sdk-go/vendor/github.com/jmespath/go-jmespath -D _/Users/kamil/go/src/github.com/uniplaces/glide-vendor-test1/vendor/github.com/aws/aws-sdk-go/aws/awsutil -I $WORK -I /Users/kamil/go/pkg/darwin_amd64 -pack ./copy.go ./equal.go ./path_value.go ./prettify.go ./string_value.go
bash-3.2$ cat main.go
package main
import (
_ "github.com/uniplaces/osin-dynamodb"
)
func main() {
panic("test")
}
I also wonder if there is a way to ignore vendor/.../vendor/
dirs to avoid some complications with including several times the same library... I know I could just rm -rf
all vendor dirs under root vendor
dir... but maybe glide provides some functionality to do that.
(beside, that, let me state this... first package manager for golang that actually works for me... great job)
@arvenil I can try to answer your questions here. And, there may be room for optimization in Glide.
First, Glide complements the go
tool. So, building binaries and so forth are handled there. This is important because any ignoring of vendor/.../vendor/
to build a binary has to happen in the go
tool. Glide can't affect that.
It's generally considered a bad practice for a library to have packages in the vendor/
folder unless they explicitly have a reason for it. For example, they are using a fork or it only works with a specific version. Otherwise you get into binary bloat and issues of sharing instances of types.
Glide does not check if a package is already in the vendor/
folder and skip downloading it. That could be another optimization.
I'm going to have to look at how glide get
is generating the lock file. The lock should have github.com/aws/aws-sdk-go
and any known dependencies. I'll check that for a bug. Thanks.
@arvenil I can explain what's happening now.
glide get
downloads a package it inspects that packages and fetches it's dependencies. The root of github.com/aws/aws-sdk-go
has no sub-packages to fetch so it doesn't. If you had should code that used it in your application it would walk the used imports and fetch more.glide up
is run to update it looks at the import path used in your code and follows those import paths to fetch everything imported. The parts of github.com/aws/aws-sdk-go
and their dependencies will be fetched when used in your application code.We can likely give this a better experience somehow.
So... for the first time I'm trying out glide (and also experimental vendor flag) and first run is a bit confusing for me. Here goes example:
My questions:
Why
glide get github.com/aws/aws-sdk-go
ended up fetching 13 dependencies? Shouldn't it just downloadgithub.com/aws/aws-sdk-go
and nothing else since this project has avendor
dir? From how it works section:Unknown github.com/lsegal/gucumber
what this means and why it's repeated so many times (making output hard to read)