Pkg3 - how to add dependencies for development only

I’d like to use Revise/Rebugger/BenchmarkTools/Plots/etc. when developing a package but if I just add them as usual they go to Project.toml and Manifest.toml. They are not real dependencies but rather convenience tools for dev only.

Is there any better way to do this i.e. make them available but not pollute the current project?

3 Likes

According to the docs, LOAD_PATH should be able to handle this.

Also, note that Base.LOAD_PATH is reset across processes. You will need a push!(Base.LOAD_PATH, /some/dir) in your startup.jl in order to make your tools persistently available.

1 Like

You don’t necessarily have to add those tools to the package Project.toml. I use the global environment, ~/.julia/environments/v1/Project.toml for e.g. Revise and BenchmarkTools.

4 Likes

I do… but as soon as I activate the environment that is used to develop the package, I lose access to the global/root environment.

This is indeed my workaround at the moment. Rather than using my package’s environment, I use the global/root environment as my primary and adjust LOAD_PATH to locate my package. However, this defeats the purpose of having a separate environment for testing my package.

Come to think of it… perhaps I should just add all those goodies in the [extras] section? It still doesn’t seem to be a clean solution since anyone adding my package will get these goodies as well.

That’s odd; I definitely don’t lose access to that environment (can still do ‘using Revise’ etc from the root environment when a project is activated). What does your LOAD_PATH look like? Does it have a "@v#.#" somewhere in it?

1 Like

You’re right. I must have messed round the environments too much and lost track. I can see how it works now. Call it a “user error” :slight_smile:

Thanks

1 Like