Skip to content
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

How do I pin the version of executables? #31

Open
stanleynguyen opened this issue Dec 19, 2017 · 6 comments
Open

How do I pin the version of executables? #31

stanleynguyen opened this issue Dec 19, 2017 · 6 comments

Comments

@stanleynguyen
Copy link

There seems to be no writeup on this matter in the documentations (aka README). I'm using vg with dep and my current way of installing executables is putting them in required field inside Gopkg.toml

@JelteF
Copy link
Contributor

JelteF commented Dec 19, 2017

Good question! By putting them in required of Gopkg.toml you are already pinning them in Gopkg.lock. The version is only updated if you run vg ensure -update or vg ensure -update github.com/user/repo-with-executable. If you want to exclude some specific (major) versions you can use a [constraint] block in your Gopkg.toml, in the same way as regular dependencies with dep.

I'll keep this open to remember to add something about it to the README for this (probably a link to dep docs).

@stanleynguyen
Copy link
Author

stanleynguyen commented Dec 20, 2017

@JelteF Thanks for the response 👍 However, I don't think this [constraint] strategy will work in the long run because according to dep README, dep prune is going to be absorbed into dep ensure. So unless you import it, all constraint package will be pruned, am I right? so there should be a way for me to do this in vg I feel

@JelteF
Copy link
Contributor

JelteF commented Dec 20, 2017

I'm asking @sdboyer about this on slack to confirm, but I'm quite sure everything that is in the required list won't be pruned. Because that's the way you can insert packages in the dependency graph that are not actually imported (as far as I know).

@JelteF
Copy link
Contributor

JelteF commented Dec 20, 2017

I got a response in the #vendor slack channel:

I just tried it myself to see how dep prune behaves with required executable. So, I created a new project and added github.com/golang/dep/cmd/dep package in required. And then I ran ensure. The whole dep repo was downloaded to vendor/. Then I ran prune, and it cleaned all the packages that are not required by github.com/goland/dep/cmd/dep package. And then I tried building dep from what was left in vendor, and it worked.
Also, when the require is added to the lock file, dep adds a list of all the packages the required package uses. And this list of project packages is used by prune to create a list of packages to keep.
So, if you add the proper package name of the executable, it's safe.
Also, you're right about using constraint to set version of a required package.

So it will keep working fine even with prune. As long as you put the actual full path to the executable package, so github.com/golang/dep/cmd/dep instead of github.com/golang/dep. Luckily, you already should do that, because otherwise vg doesn't know which package to install.

@sdboyer
Copy link

sdboyer commented Dec 20, 2017

confirming what was verified experimentally - required are equivalent to an import from a pruning perspective. wouldn't be much point in them otherwise ☺

@stanleynguyen
Copy link
Author

Thanks @JelteF @sdboyer It's clear to me now 👍

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants