Making my own first project/package - how to update/test dependencies

Hi I have made the following the following code:
Which have quite a few dependencies in it. The problem is that these dependencies are not reflected in the Project.toml, which only contains Flux (Which I initially added when I started the project and activated it)

What I would like to do now is to somehow run this code in just the packages environment, so it can tell me exactly which dependencies it is missing, so I can go in and add those to the project.toml

Any other suggestions for building my first project on things I should consider or change are very welcome!

Could you explain more why the dependencies are missing?
I am assuming you did Pkg.add for them (in the right environment)?

As for dealing with unregistered dependencies, I am not sure what the answer is. I have asked related questions twice and you may find this and this useful.

I ended up writing up my own understanding (imperfect!) here (corrections welcome).

1 Like

I added them with Pkg.add, but just into my base Julia installation. (As in I didn’t activate the project first)
The problem is that now even if I activate the project and instantiate it, it will run just fine on my Julia base. I can’t seem to find a way to run it in it’s on instantiated environment.

I read your posts and while it is similar, yours is significantly more advanced issues at this point. However I found your notes very illuminating, since I have struggled with many of the same things. I didn’t manage to figure out how to use revise or the debugger, but maybe I should give them both another go. (debugger keeps freezing on me whenever I use it, and revise just didn’t seem all that usefull)

Just pkg> activate your project and then pkg> add the dependencies there.

As for testing, there are various packages to set up a package structure using templates, with support for continuous integration using services like Travis. Eg

(disclaimer: the last one is mine)

1 Like

There seems to be a misunderstanding regarding environment stacks.

In general, the active environment is not the only environment that you can load packages from. The active environment is the environment that is modified when you run Pkg operations.

The variable LOAD_PATH determines the complete set of packages that are available at any given moment i.e. the environment stack. By default, environment stack looks like this:

active environment (top of stack)
default (or "base") environment
stdlibs (bottom of stack)

You can see the concrete locations with Base.load_path().

@tue I think you are looking to isolate the active environment? If so, you can do

push!(LOAD_PATH, "@stdlib")
push!(LOAD_PATH, "@")

This will make it so you can only load stdlibs or packages from your active environment.

1 Like

I think that is exactly what I’m looking for. Just one quick question before I do this, would my environment be set back to normal when I restart Julia or how would I get it back to normal afterwards again?

Yeah, this is only per process (like any regular variable). Restarting julia will reset LOAD_PATH.

But a more direct way is:

# modify and use modified LOAD_PATH here
# now reset
    push!(LOAD_PATH, x)
1 Like