Pkg problem with Julia 1.1

I’m testing an updated package developed by a collaborator. The updated package doesn’t install; instead, the old package (which I have renamed on my computer) gets installed. I use Julia v. 1.1 on Windows 10, 64 bit, latest version.

The updated package is available on collaborator’s github site, but I have also downloaded it manually and put it on my hard drive. I have added the path of the package in my .julia/config/startup.jl file. Here is what I do:

  • I use Pkg manager to remove the old version, Pkg.rm(“pkgname”).
  • I go into the .julia/packages directory and delete the directory associated with the package.
  • I restart my computer.
  • I add the package using the Pkg manager

Although I have renamed the old package, it is still the old package that is available when I import the package into Julia. So the old package must be stored somewhere in the Julia system without me knowing it… and in such a way that the old package gets installed instead of the new package.

Questions:

  1. Where could the old package be stored? Is there a way to remove it ( Pkg.rm(“pkgname”) ) doesn’t remove it properly from the system…
  2. I assume that the reason why the package is not properly removed/handled is that something is missing in the package set-up. What could this this missing set-up be?

It is better to just pkg> add or pkg> dev it in your default environment.

These steps should not be necessary.

To answer this, it would be good to know what exactly you do in .startup.jl, but note that this is not the way to do it. See

https://julialang.github.io/Pkg.jl/v1/managing-packages/#Adding-unregistered-packages-1

2 Likes

Pkg.add(path to github) does it.

This downloads the latest commit from the repo (or the one that you specify with an sha).

1 Like

Please write down your exact commands that you use and what output you get. Stuff like I add the package using the Pkg manage could mean a lot of different things.

2 Likes

Sorry for delayed response – I was out on a hike…

OK: I removed the package using Pkg.rm("pkg_name"). Then I deleted my “private” download. Finally, I tried to Pkg.add("github_address"). I’m then told that the “github_address” is not a valid address. So I do Pkg.clone("github_address"). I’m then told that clone is outdated, and that I should use add – but it still procedes to try to install the package…

julia> Pkg.clone("https://github.com/software/pkg_name.jl")
┌ Warning: Pkg.clone is only kept for legacy CI script reasons, please use `add`
└ @ Pkg.API C:\cygwin\home\Administrator\buildbot\worker\package_win64\build\usr\share\julia\stdlib\v1.1\Pkg\src\API.jl:391
  Updating registry at `C:\Users\myself\.julia\registries\General`
  Updating git-repo `https://github.com/JuliaRegistries/General.git`
  Updating git-repo `https://github.com/software/pkg_name.jl`
[ Info: Path `C:\Users\myself\.julia\dev\pkg_name` exists and looks like the correct package, using existing path
 Resolving package versions...
  Updating `C:\Users\myself\.julia\environments\v1.1\Project.toml`
  [0f4fe800] + pkg_name v0.1.0+ [`C:\Users\myself\.julia\dev\pkg_name`]
  Updating `C:\Users\myself\.julia\environments\v1.1\Manifest.toml`
  [0f4fe800] + pkg_name v0.1.0+ [`C:\Users\myself\.julia\dev\pkg_name`]
  1. OK… Pkg.add() doesn’t work, but Pkg.clone() works with a warning. Am I supposed to use Pkg.dev() here?
  2. I observe that an old version of the package is located at .julia\dev\… and in fact the package manager thinks this is the same as the one I try to install. I guess that because of this, the Pkg manager actually doesn’t install the new code…??
  3. Why does the package manager confuse the two versions of the package. Hm… I asked the developer for the version number of the new code. My impression is that they have not specified the version number, or that they perhaps use the same version number for both the old version and the new version. Could this explain the confusion of the package manager?

I next experimented with the dev command. I thus removed the package again (Pkg.rm("pkg_name")), and then tried Pkg.dev("https://github.com/software/pkg_name.jl"). Response: dev is not defined. Then I switched to the Pkg environment and did pkg> dev https://github.com/software/pkg_name.jl. This time, the software was installed. But with the same comment as before that the package already was installed…

Question: Is it correct that dev is not available from Pkg.dev() ? (I tend to import Pkg and use the syntax Pkg.command() because this can be scripted…)

Finally, I have deleted directory pkg_name from .julia\dev\ as well as from .julia\packages\. Next, I used Pkg.clone() to install the package from github.

This time, there was no complaint that the the package already existed in dev subdirectory, and the new package was installed in .julia\dev\… And this time, nothing was installed in .julia\packages

What bugs me is that the code still behaves like the old version…

If you insist on that API, it is Pkg.develop.

(Doing this by trial and error may be somewhat frustrating, perhaps consider reading the docs).

It will not overwrite existing directories:

https://julialang.github.io/Pkg.jl/dev/managing-packages/#Developing-packages-1

But pkg> up should update to the latest version.

You may find pkg> status useful in investigating problems like this.

1 Like

You are just using the function wrong, if you look at the docstring:

help?> Pkg.add
  Pkg.add(pkg::Union{String, Vector{String}})
  Pkg.add(pkg::Union{PackageSpec, Vector{PackageSpec}})

  Add a package to the current project. This package will be available using the import and using keywords in the Julia REPL and if the current project is a package, also inside that package.

  Examples
  ≡≡≡≡≡≡≡≡≡≡

  Pkg.add("Example") # Add a package from registry
  Pkg.add(PackageSpec(name="Example", version="0.3")) # Specify version
  Pkg.add(PackageSpec(url="https://github.com/JuliaLang/Example.jl", rev="master")) # From url to remote gitrepo
  Pkg.add(PackageSpec(url="/remote/mycompany/juliapackages/OurPackage"))` # From path to local gitrepo

  See also PackageSpec.

you see that the correct usage is

Pkg.add(PackageSpec(url = "github _adress"))
3 Likes

Thanks! I’ll test it out – probably tomorrow.

What about if there is no “version” specified in the package? Would that cause problems if I try to add the package, and the package manager finds another version without version specification? Will the package manager believe that the packages are the same?

No, there will be no confusion. add retrieves the latest from github (unless you specify an sha in the PackageSpec, but specifying an sha may only work for up, the way I read the Pkg docs).

And, as the docs say, but potentially easy to overlook:

Pkg.add(PackageSpec(...))

but

pkg> add https://github.com/path/to/package

2 Likes

Thanks again. Pkg.add(PackageSpec(url="...githubaddress...")) solved the problem.