Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Force a specific version for a dependency when using dep

I am using dep to manage the dependencies of a Go tool I'm writing.

This tool uses https://github.com/desertbit/grumble as an dependency. This in turn uses https://github.com/chzyer/readline as a dependency. The problem is that when trying to run my tool I get the following error: vendor/github.com/desertbit/grumble/app.go:295:20: unknown field 'HistorySearchFold' in struct literal of type readline.Config

I know why this is happending. grumble uses the master branch of readline as a dependency. In this the field HistorySearchFold is available. When using dep init/dep ensure not the master but the 1.4 tag is pulled into the vendor folder.

My question therefore is: How can I force dep to pull the master branch instead?

I tried adding the following in my Gopkg.toml file:

[[constraint]]
  branch = "master"
  name = "github.com/chzyer/readline"

Sadly this is not working. When I check the version pulled into the vendor folder it is still 1.4.

like image 608
Christian Avatar asked Jan 20 '18 20:01

Christian


People also ask

Is DEP deprecated?

GitHub - golang/dep: Go dependency management tool experiment (deprecated)

What does DEP init do?

By default, dep init will look in your codebase for metadata files from other Go package management tools that it understands, and attempt to automatically migrate the data in these files into concepts that make sense in a dep.

What is DEP command?

The Dependent Definition (DEP) command definition statement defines a required relationship between parameters and parameter values that must be checked. This relationship can refer to either the specific value of a parameter or parameters, or to the required presence of parameters.


1 Answers

If you are trying to control the version of a transient dependency (not one directly used by your package, you should use the [[override]] directive

It looks exactly the same as a constraint, but it will constrain dependencies even when not directly inherited by your package.

[[override]]
  branch = "master"
  name = "github.com/chzyer/readline"

Note that this is also useful for when the dependency solver finds conflicting dependencies, e.g. your package P makes use of packages A and B, and both depend on different versions of package X... you can use an override on package X inside of your package P

like image 122
Crast Avatar answered Sep 24 '22 22:09

Crast