I have a private package that I am trying to test. When I run the test suite, it fails, claiming it can’t find CSV:
ERROR: LoadError: ArgumentError: Package CSV not found in current path:
- Run `import Pkg; Pkg.add("CSV")` to install the CSV package.
Stacktrace:
[1] require(::Module, ::Symbol) at ./loading.jl:887
[2] include at ./boot.jl:328 [inlined]
[3] include_relative(::Module, ::String) at ./loading.jl:1105
[4] include(::Module, ::String) at ./Base.jl:31
[5] include(::String) at ./client.jl:424
[6] top-level scope at none:6
in expression starting at /home/doomphoenix/.julia/dev/MoltenSaltThermodynamics/test/runtests.jl:3
ERROR: Package MoltenSaltThermodynamics errored during testing
This despite the fact that CSV is clearly listed as a dependency (in the Project.toml):
I don’t have a separate Project.toml in test, but that is a good thing to keep in mind and something I was unaware of. Yes, I am using CSV in runtests.jl. Judging from the tone of your question, this seems to be the problem, but I’m not sure why that’s the case?
I had exactly the same problem over the weekend, but when I went now to make a little MWE, I found the problem installing CSV had gone away. The problem only happened when you ran Pkg.test(); just running the tests directly from the command line worked fine. Could there have been some corruption problem with the main registry, perhaps?
[...]
ERROR: LoadError: LoadError: ArgumentError: Package CSV not found in current path:
- Run `import Pkg; Pkg.add("CSV")` to install the CSV package.
Stacktrace:
[1] require(::Module, ::Symbol) at ./loading.jl:892
[2] include(::Module, ::String) at ./Base.jl:377
[3] include(::String) at /home/travis/build/grahamstark/ScottishTaxBenefitModel.jl/src/ScottishTaxBenefitModel.jl:1
[4] top-level scope at /home/travis/build/grahamstark/ScottishTaxBenefitModel.jl/src/ScottishTaxBenefitModel.jl:10
[5] include(::Module, ::String) at ./Base.jl:377
[6] top-level scope at none:2
[7] eval at ./boot.jl:331 [inlined]
[8] eval(::Expr) at ./client.jl:449
[9] top-level scope at ./none:3
What I had in mind was that you might be calling a CSV function in the tests without using CSV in runtests.jl, but that doesn’t seem to be the problem.
Then I’m afraid it’s hard to figure out the problem without a MWE.
It might be easier than that: if you don’t have a separate environment for the tests, include all the packages used in runtests.jl in the corresponding target of the package’s Project.toml, for instance:
[targets]
test = ["Test", "CSV", "MoltenSaltThermodynamics"]
Thanks everyone for the help! In the end I was able to solve the problem by creating a specific environment for testing as described in the link that @hendri54 posted. That seems to be the best way of going about this. I didn’t know that Julia had added that capability, but it shows me that I should read the Pkg documentation more carefully!