I’m developing a package which is stored in my Github rep but not registered with Julia. I have the dev
version in the .julia/dev
directory, and I also install the normal version from Github in the .julia/packages
directory. But how do I switch between these two versions? I tried to free
the dev
version of the package but it doesn’t work: ERROR: unable to free unregistered package
.
Any reason why can’t just add the unregistered package by its url?
(v1.1) pkg> add https://github.com/JuliaLang/Example.jl
(from Pkg · The Julia Language)
That’s a package prompt I haven’t seen in a while
Correct me if I am wrong but I have this impression that if you want to use the registered version of the package in your script or function you go
Pkg.add Example
and if you want to use the development version go
Pkg.dev Example
Yeah, Julia 1.1 - maybe time to upgrade
Yes. I can move to the dev version by dev
, but how to I go back to the normal version? Do I have to add
the normal version from github every time I use it?
You can use free
help?> Pkg.free
Pkg.free(pkg::Union{String, Vector{String}}; io::IO=stderr, all_pkgs::Bool=false)
Pkg.free(pkgs::Union{PackageSpec, Vector{PackageSpec}}; io::IO=stderr, all_pkgs::Bool=false)
If pkg is pinned, remove the pin. If pkg is tracking a path, e.g. after Pkg.develop, go
back to tracking registered versions. To free all dependencies set all_pkgs=true.
│ Julia 1.7
│
│ The all_pkgs kwarg was introduced in julia 1.7.
Examples
≡≡≡≡≡≡≡≡≡≡
Pkg.free("Package")
Pkg.free(all_pkgs = true)
That doesn’t work because the package is not registered:
ERROR: unable to free unregistered package
Ahh, right. Missed that part.
Would guess the easiest is then to add/dev back and forth if you need to.
Or, depending on your use case, maybe you can split it up in different envs, one with add and one with dev, and just switch between them?
You can create your own registry where you add your package. You don’t need to add any versions, but just having the relevant Package.toml
file in your registry makes it possible to at least to pkg> add Package#master
(or any other git revision).
And to make this easier:
Another option that I would use (but requires some comfort with git) would be sticking with the one in your ~/.julia/dev
directory, and just doing git checkout devbranch
and git checkout v0.whatever #the release version
.