Dep: Prune options have inconsistent behaviour with document description

Created on 16 Mar 2018  路  3Comments  路  Source: golang/dep

https://golang.github.io/dep/docs/Gopkg.toml.html#prune

As document description, prune should allow non-go = false options to prevent files discarded by dep, but I got an error output when use this option with dep ensure.

error while parsing /Users/jiangjinyang/workspace/go/src/test/Gopkg.toml: manifest validation failed: root prune options must be omitted instead of being set to false

So I remove prune section from Gopkg.toml, and run dep ensure again. I found "non-go" files under vendor dir is discarded, this behaviour is not according document description.

# document behaviour
Pruning is disabled by default. It can be enabled by setting them to true at the root level.

I'd like to contribute PR, but the behaviour of prune options is so stranger and not clear.

What version of dep are you using (dep version)?

v0.4.1
v0.4.1-114-gc55e7a6d

What dep command did you run?

  1. Run dep init
  2. Update Gopkg.toml, set non-go = false
  3. Run dep ensure, got error output
  4. Update Gopkg.toml, remove prune section.
  5. Create a non-go file, echo "test" > vendor/test
  6. Run dep ensure, no error occurred, but vendor/test is discarded
error while parsing /Users/jiangjinyang/workspace/go/src/test/Gopkg.toml: manifest validation failed: root prune options must be omitted instead of being set to false
# Gopkg.toml
[prune]
  non-go = false
  go-tests = true

What did you expect to see?

vendor/test should not been discarded.
non-go option should allow false option, and default options of non-go should e false.

What did you see instead?

prune options is not allow false options, and behaviour is very different with document description.

All 3 comments

Seem new vendor dir not include non-go file, so it looks like "non-go" files are discarded.
https://github.com/golang/dep/blob/master/txn_writer.go#L410

Could you please clarify what files should exist but get pruned anyway? It would be helpful if you can specify the project or provide reproduction steps.

@jjyr ah, i can see how the docs about this might be confusing.

It is NOT the goal of pruning to allow you to toss arbitrary stuff in the vendor directory and have it be preserved. Rather, the purpose of pruning is to decide what subset of files that exist in the upstream source should be removed from vendor.

dep wholly controls the vendor directory. If there are files that dep doesn't know the provenance of, it removes them. That's the design, and we can't provide the strong guarantees we aim to without that.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

michael-go picture michael-go  路  3Comments

rustyx picture rustyx  路  3Comments

alecthomas picture alecthomas  路  3Comments

abeMedia picture abeMedia  路  3Comments

deejross picture deejross  路  3Comments