# Package development tools - in environment but not dependency

**URL:** <https://discourse.julialang.org/t/package-development-tools-in-environment-but-not-dependency/81960>\
**Category:** Performance\
**Tags:** package, testing\
**Created:** [May 31, 2022, 5:56am UTC](https://discourse.julialang.org/t/package-development-tools-in-environment-but-not-dependency/81960 "2022-05-31T05:56:39Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![Philippe\_Maincon1](https://avatars.discourse-cdn.com/v4/letter/p/ec9cab/32.png) [@Philippe\_Maincon1](https://discourse.julialang.org/u/Philippe_Maincon1)\
**Post date:** [May 31, 2022, 5:56am UTC](https://discourse.julialang.org/t/package-development-tools-in-environment-but-not-dependency/81960/1 "2022-05-31T05:56:40Z")

</div>

Hi,

I am getting a package `EspyInsideFunction.jl` fairly formalized (testing, doc, registration…). But I still wonder about one thing: as part of development work I use `Documenter.jl`, `Test.jl` and `ProfileView.jl`, so they must be in the package’s environment. But I do not want to force these tools to be installed as dependencies on the computer of someone _using_ my package, so they must not be in the package’s environment.

Please correct my statements were needed (there has to be one or several correction, because things do not work as I describe them!)

1. When developing (testing, documenting) a package, I activate that package’s environment. I do not use a separate “develop\_EspyInsideFunction” environment.
2. In the `Project.toml` file, I have

```julia
name = "EspyInsideFunction"
uuid = "d6b55740-5cb4-11ec-1cb9-93db9984c461"
authors = ["Philippe Maincon <philippe.maincon@sintef.no>"]
version = "0.2.0"

[deps]
Printf = "de0858da-6303-5e67-8744-51eddeeeb8d7"

[compat]
julia = "1.6"

[extras]
Test = "8dfed614-e22c-5e08-85e1-65c5234f0b40"
Documenter = "e30172f5-a6a5-5a46-863b-614d45cd2de4"

[targets]
test = ["Test"]

```

`[extras]` is for development tools that are not dependencies of my package.

1. To get `Test` and `Documenter` in `[extras]` I first `] add` these packages, then manualy move the references from `[deps` to `[extras]` in `Project.toml`.

As said, that’s in my dreams. With `Project.toml` as above, launching the test suite (including doctests) crashes:

```julia
ERROR: ArgumentError: Package Documenter not found in current path:
- Run `import Pkg; Pkg.add("Documenter")` to install the Documenter package.

```

What am I doing wrong?

😀

---

<div class="post-metadata">

**Author:** ![gdalle](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/gdalle/32/27854_2.png) [@gdalle](https://discourse.julialang.org/u/gdalle)\
**Post date:** [May 31, 2022, 6:02am UTC](https://discourse.julialang.org/t/package-development-tools-in-environment-but-not-dependency/81960/2 "2022-05-31T06:02:16Z")

</div>

As soon as you move the test dependencies from `[deps]` to `[extras]`, they are no longer available in the package environment `EspyInsideFunction`. I have found two solutions for that:

- Use [TestEnv.jl](https://github.com/JuliaTesting/TestEnv.jl) to activate your test environment and develop in it.
- Put some common test dependencies in your base environment `@v1.7`. Of course you still have to keep them in `[extras]`, but if they are packages that you commonly use then it may be worth it. I do this for lightweight packages related to documentation, profiling, benchmarking, etc.

---

<div class="post-metadata">

**Author:** ![Philippe\_Maincon1](https://avatars.discourse-cdn.com/v4/letter/p/ec9cab/32.png) [@Philippe\_Maincon1](https://discourse.julialang.org/u/Philippe_Maincon1)\
**Post date:** [May 31, 2022, 6:46am UTC](https://discourse.julialang.org/t/package-development-tools-in-environment-but-not-dependency/81960/3 "2022-05-31T06:46:46Z")

</div>

Without having tried it out, `TestEnv.jl` allows to make the `[extras]` available for testing only, using e.g.

```julia
using TestEnv, ReTest
TestEnv.activate("Example") do
    retest()
end

```

Looks perfect, I’ll try that. Oh and `ReTest.jl` is worth trying.

About your second suggestion, for the sake of better understanding environments: you propose to use a separate enviroment `@v1.7` in which `Test.jl` etc. are installed. To test, one would activate this `@v1.7` environment and `runtest`. Two questions:

1. I would need to `] dev EspyInsideFunction` in that environment, right?
2. In `@v1.7`, `Test.jl` would have to be in `[deps]`, not `[extras]` - otherwise these packages will not be available (unless using `TestEnv`. But why do you say " ou still have to keep them in `[extras]`"?

🙂

---

<div class="post-metadata">

**Author:** ![gdalle](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/gdalle/32/27854_2.png) [@gdalle](https://discourse.julialang.org/u/gdalle)\
**Post date:** [May 31, 2022, 7:04am UTC](https://discourse.julialang.org/t/package-development-tools-in-environment-but-not-dependency/81960/4 "2022-05-31T07:04:35Z")

</div>

About the second suggestion, `@v1.7` is actually the name of your default Julia environment, the one that pops up when you run `julia` in a terminal. This base environment is always stacked _underneath_ any activated environment, so that packages installed there are available everywhere

---

<div class="post-metadata">

**Author:** ![gdalle](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/gdalle/32/27854_2.png) [@gdalle](https://discourse.julialang.org/u/gdalle)\
**Post date:** [May 31, 2022, 7:05am UTC](https://discourse.julialang.org/t/package-development-tools-in-environment-but-not-dependency/81960/5 "2022-05-31T07:05:37Z")

</div>

For instance, here’s what I have in mine:

```julia
(@v1.7) pkg> st
      Status `~/.julia/environments/v1.7/Project.toml`
  [6e4b80f9] BenchmarkTools v1.3.1
  [e30172f5] Documenter v0.27.18
  [98e50ef6] JuliaFormatter v1.0.2
  [5fb14364] OhMyREPL v0.5.12
  [65465c31] PackageCompatUI v1.0.2
  [14b8a8f1] PkgTemplates v0.7.28
  [c3e4b0f8] Pluto v0.19.5
  [295af30f] Revise v3.3.3
  [1e6cf692] TestEnv v1.7.3

```

---

<div class="post-metadata">

**Author:** ![Philippe\_Maincon1](https://avatars.discourse-cdn.com/v4/letter/p/ec9cab/32.png) [@Philippe\_Maincon1](https://discourse.julialang.org/u/Philippe_Maincon1)\
**Post date:** [May 31, 2022, 7:18am UTC](https://discourse.julialang.org/t/package-development-tools-in-environment-but-not-dependency/81960/6 "2022-05-31T07:18:47Z")

</div>

It’s the stacking idea that I had missed: so having packed my default envronment with development tools, I activate the environment of `EspyInsideFunction`, and run all my tests.

An implication is that I must be very careful not to have any packages in my base environment, that could be a dependency of my package: I might forget to add the dependency to my package environment, yet have my tests succeed. So for example, if I want to have an environment packed with plotting and algebra goodies (think of PyLab), for REPLing and scripting, I will make very sure it’s _not_ the deffault `@v1.7`.

I think that’s my preferred solution. Thanks a bunch!

---

<div class="post-metadata">

**Author:** ![gdalle](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/gdalle/32/27854_2.png) [@gdalle](https://discourse.julialang.org/u/gdalle)\
**Post date:** [May 31, 2022, 7:20am UTC](https://discourse.julialang.org/t/package-development-tools-in-environment-but-not-dependency/81960/7 "2022-05-31T07:20:44Z")

</div>

Another reason you don’t want your base environment too packed is that it can cause compatibility problems during stacking. I’ve encountered this a few times, which is why I keep it light nowadays
