Install a specific commit for unregistered package?

I’m trying to install a specific commit of a unregistered package. I tried with Pkg.pin but that’s only available with registered packages; and Pkg.clone does not have any method for that. Is it possible to install a specific commit of a repo? I’m in 0.6.2.

clone and then checkout?

2 Likes

Easiest way is to clone, open up GitKraken, click to make a branch at that commit, and then stay there.

Do you mean something like this?

Pkg.clone("<pkg name>")
repo = LibGit2.GitRepo(joinpath(Pkg.dir(), "<pkg name>"))
LibGit2.branch!(repo, "Pin_<sha commit>", "<sha commit>")

New branch is necessary to avoid Pkg.update() to “unpin”… ? (I didn’t check it)

No, just call Pkg.clone and then Pkg.checkout.

I only have the SHA of the commit. The package doesn’t have any branches, just master and many commits. Pkg.checkout expects a branch.

Ah, too bad. I wonder why, given that git commands generally accept either a branch or a commit.

Just go to .julia/v0.6/Package and checkout the commit.

[2 years later]

Julia and the Pkg system moved forward quite a bit. Is this still the way to pin an unregistered package?

Specifically, I want to use a pinned version of a package in one project and another version (say the master version) in another project.