Pkg.test does not recognize package dependencies

Hello,

I am writing a Julia package. I already have a few releases, so I got the basics working. I just added another function and I added the new dependency on Statistics, like so:

(Planets) pkg> resolve
 Resolving package versions...
  Updating `Project.toml`
 [no changes]
  Updating `Manifest.toml`
 [no changes]

The first time I ran this Project.toml and Manifest.toml were updated so that now they include the Statistics package. For example, Manifest.toml contains this bit:

[[Statistics]]
deps = ["LinearAlgebra", "SparseArrays"]
uuid = "10745b16-79ce-11e8-11f9-7d13ad32a3b2"

So now I want to run the new tests that I’ve added, and that’s where I run into trouble. The test feature doesn’t realize that I’ve already added Statistics as a dependency:

Varda ~/Science/Planets.jl % julia
               _
   _       _ _(_)_     |  A fresh approach to technical computing
  (_)     | (_) (_)    |  Documentation: https://docs.julialang.org
   _ _   _| |_  __ _   |  Type "?" for help, "]?" for Pkg help.
  | | | | | | |/ _` |  |
  | | |_| | | | (_| |  |  Version 0.7.0 (2018-08-08 06:46 UTC)
 _/ |\__'_|_|_|\__'_|  |  Official http://julialang.org/ release
|__/                   |  x86_64-pc-linux-gnu

(v0.7) pkg> activate .

(Planets) pkg> test
   Testing Planets
 Resolving package versions...
WARNING: Method definition intern(Type{WeakRefStrings.WeakRefString{UInt8}}, Tuple{Ptr{UInt8}, Int64}) in module Parsers at /home/daniel/.julia/packages/Parsers/kL0P9/src/strings.jl:17 overwritten in module CSV at /home/daniel/.julia/packages/CSV/uLyo0/src/CSV.jl:5.
ERROR: LoadError: LoadError: ArgumentError: Package Planets does not have Statistics in its dependencies:
- If you have Planets checked out for development and have
  added Statistics as a dependency but haven't updated your primary
  environment's manifest file, try `Pkg.resolve()`.
- Otherwise you may need to report an issue with Planets
Stacktrace:
 [1] require(::Module, ::Symbol) at ./loading.jl:830
 [2] include at ./boot.jl:317 [inlined]
 [3] include_relative(::Module, ::String) at ./loading.jl:1038
 [4] include at ./sysimg.jl:29 [inlined]
 [5] include(::String) at /home/daniel/Science/Planets.jl/src/Planets.jl:1
 [6] top-level scope at none:0
 [7] include at ./boot.jl:317 [inlined]
 [8] include_relative(::Module, ::String) at ./loading.jl:1038
 [9] include(::Module, ::String) at ./sysimg.jl:29
 [10] top-level scope at none:2
 [11] eval at ./boot.jl:319 [inlined]
 [12] eval(::Expr) at ./client.jl:399
 [13] top-level scope at ./none:3
in expression starting at /home/daniel/Science/Planets.jl/src/isochrone.jl:8
in expression starting at /home/daniel/Science/Planets.jl/src/Planets.jl:9
ERROR: LoadError: Failed to precompile Planets [7a3fd1c8-cccc-11e8-1991-ff9663c7a777] to /home/daniel/.julia/compiled/v0.7/Planets/RNNVP.ji.
Stacktrace:
 [1] error(::String) at ./error.jl:33
 [2] macro expansion at ./logging.jl:313 [inlined]
 [3] compilecache(::Base.PkgId, ::String) at ./loading.jl:1185
 [4] _require(::Base.PkgId) at ./logging.jl:311
 [5] require(::Base.PkgId) at ./loading.jl:852
 [6] macro expansion at ./logging.jl:311 [inlined]
 [7] require(::Module, ::Symbol) at ./loading.jl:834
 [8] include at ./boot.jl:317 [inlined]
 [9] include_relative(::Module, ::String) at ./loading.jl:1038
 [10] include(::Module, ::String) at ./sysimg.jl:29
 [11] include(::String) at ./client.jl:398
 [12] top-level scope at none:0
in expression starting at /home/daniel/Science/Planets.jl/test/runtests.jl:2
ERROR: Package Planets errored during testing

(Planets) pkg> 

I’m really stuck here. Can anyone figure what’s going on? It’s complaining that I have not added Statistics to the list of dependencies, but it’s right there in the .toml files. Does anyone know what to do here?

Cheers,
Daniel

What does

(Planets) pkg> st

say?

Can you show your full Project file?

Hmm… st is missing Statistics:

(Planets) pkg> st
Project Planets v0.1.0
    Status `Project.toml`
  [336ed68f] CSV v0.4.1
  [a93c6f00] DataFrames v0.14.1
  [e1d29d7a] Missings v0.3.1

It looks like Statistics was added to Manitfest.toml but not to Project.toml. Can you explain the difference between those two files?

name = "Planets"
uuid = "7a3fd1c8-cccc-11e8-1991-ff9663c7a777"
authors = ["Daniel Carrera <dcarrera@gmail.com>"]
version = "0.1.0"

[deps]
CSV = "336ed68f-0bac-5ca0-87d4-7b16caf5d00b"
DataFrames = "a93c6f00-e57d-5684-b7b6-d8193f3e46c0"
Missings = "e1d29d7a-bbdc-5cf2-9ac0-f12de2c33e28"

[compat]
julia = "0.7"

[extras]
Test = "8dfed614-e22c-5e08-85e1-65c5234f0b40"

[targets]
test = ["Test"]

So I just added Statistics = "10745b16-79ce-11e8-11f9-7d13ad32a3b2" inside the [deps] section and now I’m getting different errors that don’t seem to have anything to do with dependencies.

1 Like

My guess is you added it to the wrong environment.

Project is similar to REQUIRE, you list what you depend on.

Manifest is like a snapshot of the result of the resolution algorithm. It records what packages depends on what and what versions everything is installed at.

In order for your package to be able to load a dependency, it needs to exist in the Project.

So what you need to do here is likely just Pkg.add("Statistics").

1 Like