# Testing private package fails based on dependency

**URL:** <https://discourse.julialang.org/t/testing-private-package-fails-based-on-dependency/41619>\
**Category:** General Usage\
**Created:** [June 17, 2020, 6:28pm UTC](https://discourse.julialang.org/t/testing-private-package-fails-based-on-dependency/41619 "2020-06-17T18:28:52Z")\
**Posts on this page:** 9\
**Page:** 1

<div class="post-metadata">

**Author:** ![doomphoenix-qxz](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/doomphoenix-qxz/32/7009_2.png) [@doomphoenix-qxz](https://discourse.julialang.org/u/doomphoenix-qxz)\
**Post date:** [June 17, 2020, 6:28pm UTC](https://discourse.julialang.org/t/testing-private-package-fails-based-on-dependency/41619/1 "2020-06-17T18:28:52Z")

</div>

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`:

```julia
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):

```julia
[deps]
CSV = "336ed68f-0bac-5ca0-87d4-7b16caf5d00b"
DataFrames = "a93c6f00-e57d-5684-b7b6-d8193f3e46c0"
LaTeXStrings = "b964fa9f-0449-5b57-a5c2-d3ea65f4040f"
LinearAlgebra = "37e2e46d-f89d-539d-b4ee-838fcccc9c8e"
LsqFit = "2fda8390-95c7-5789-9bda-21331edee243"
Plots = "91a5bcdd-55d7-5caf-9e0b-520d859cae80"
Statistics = "10745b16-79ce-11e8-11f9-7d13ad32a3b2"

[compat]
julia = "1"

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

[targets]
test = ["Test"]

```

This does not appear to me to be expected behavior. What am I missing?

I am not the only one who has come across this either, see [https://discourse.julialang.org/t/confused-by-pkg-test-behavior/35500](https://discourse.julialang.org/t/confused-by-pkg-test-behavior/35500).  
Thanks!

---

<div class="post-metadata">

**Author:** ![hendri54](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/hendri54/32/9621_2.png) [@hendri54](https://discourse.julialang.org/u/hendri54)\
**Post date:** [June 17, 2020, 6:43pm UTC](https://discourse.julialang.org/t/testing-private-package-fails-based-on-dependency/41619/2 "2020-06-17T18:43:43Z")

</div>

A little more info would be helpful (ideally as a MWE).

Do you have, by any chance, a separate `test/Project.toml` from which `CSV` is missing? Cf [5. Creating Packages · Pkg.jl](https://julialang.github.io/Pkg.jl/v1/creating-packages/#Test-specific-dependencies-in-Julia-1.2-and-above-1)

Sorry to ask, but is has happened to me before: you are `using CSV` in `runtests.jl`?

---

<div class="post-metadata">

**Author:** ![doomphoenix-qxz](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/doomphoenix-qxz/32/7009_2.png) [@doomphoenix-qxz](https://discourse.julialang.org/u/doomphoenix-qxz)\
**Post date:** [June 17, 2020, 8:23pm UTC](https://discourse.julialang.org/t/testing-private-package-fails-based-on-dependency/41619/3 "2020-06-17T20:23:08Z")

</div>

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?

Thanks for the help.

---

<div class="post-metadata">

**Author:** ![grahamstark](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/grahamstark/32/5200_2.png) [@grahamstark](https://discourse.julialang.org/u/grahamstark)\
**Post date:** [June 17, 2020, 9:24pm UTC](https://discourse.julialang.org/t/testing-private-package-fails-based-on-dependency/41619/4 "2020-06-17T21:24:36Z")

</div>

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?

Graham

---

<div class="post-metadata">

**Author:** ![grahamstark](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/grahamstark/32/5200_2.png) [@grahamstark](https://discourse.julialang.org/u/grahamstark)\
**Post date:** [June 17, 2020, 9:38pm UTC](https://discourse.julialang.org/t/testing-private-package-fails-based-on-dependency/41619/5 "2020-06-17T21:38:42Z")

</div>

actually, I still get the error in Travis:

> **[Travis CI - Test and Deploy with Confidence](https://app.travis-ci.com/github/grahamstark/ScottishTaxBenefitModel.jl)**
>
> Travis CI enables your team to test and ship your apps with confidence. Easily sync your projects with Travis CI and you'll be testing your code in minutes.

```julia
[...]
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

```

---

<div class="post-metadata">

**Author:** ![hendri54](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/hendri54/32/9621_2.png) [@hendri54](https://discourse.julialang.org/u/hendri54)\
**Post date:** [June 18, 2020, 11:46am UTC](https://discourse.julialang.org/t/testing-private-package-fails-based-on-dependency/41619/6 "2020-06-18T11:46:19Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![Tero\_Frondelius](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/tero_frondelius/32/7629_2.png) [@Tero\_Frondelius](https://discourse.julialang.org/u/Tero_Frondelius)\
**Post date:** [June 18, 2020, 12:08pm UTC](https://discourse.julialang.org/t/testing-private-package-fails-based-on-dependency/41619/7 "2020-06-18T12:08:15Z")

</div>

Maybe, the same solution works here: [CSV Parsers dependency problem](https://discourse.julialang.org/t/csv-parsers-dependency-problem/23827)

> [@CSV Parsers dependency problem](https://discourse.julialang.org/t/csv-parsers-dependency-problem/23827/2):
>
> I think the issue is that the previous CSV.jl release probably has a dependency version like “Parsers \>= 0.2” or something, and then when Parsers.jl made a breaking release to `0.3.0` , it breaks CSV.jl. I think if you do something like `] pin Parsers 0.2.22` , it should fix it for now.

---

<div class="post-metadata">

**Author:** ![heliosdrm](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/heliosdrm/32/3851_2.png) [@heliosdrm](https://discourse.julialang.org/u/heliosdrm)\
**Post date:** [June 18, 2020, 2:31pm UTC](https://discourse.julialang.org/t/testing-private-package-fails-based-on-dependency/41619/8 "2020-06-18T14:31:24Z")

</div>

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:

```nohighlight
[targets]
test = ["Test", "CSV", "MoltenSaltThermodynamics"]

```

---

<div class="post-metadata">

**Author:** ![doomphoenix-qxz](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/doomphoenix-qxz/32/7009_2.png) [@doomphoenix-qxz](https://discourse.julialang.org/u/doomphoenix-qxz)\
**Post date:** [June 18, 2020, 6:39pm UTC](https://discourse.julialang.org/t/testing-private-package-fails-based-on-dependency/41619/9 "2020-06-18T18:39:42Z")

</div>

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!
