Travis CI fails for Julia v0.7 since Test package missing

Thanks. I tested and this works. However, if one would like to go back to the standard environment, one needs to reactivate the standard environment again. So the complete number of commands would be:

using Pkg
Pkg.activate("path/to/examples")
Pkg.instantiate()
include("path/to/examples/Simulate_FreeBodyRotation.jl")
Pkg.activate("path/to/environments/v1.0")

When adding ModiaMath, the user does not know where ModiaMath is really installed. Therefore, to make the example completely correct, the following commands would have to be given:

using Pkg
import ModiaMath
Pkg.activate("$(ModiaMath.path)/examples")
Pkg.instantiate()
include("$(ModiaMath.path)/examples/Simulate_FreeBodyRotation.jl")
Pkg.activate("path/to/environments/v1.0")

At least I understand now this (clean) approach.

De-activating can be done with Pkg.activate(), instead of activating the default one (which might not be where the user where before activating the examples env).

1 Like

De-activating can be done with Pkg.activate() , instead of activating the default one (which might not be where the user where before activating the examples env).

O.k. this is nice (did not know this).

I just recognized that the “instantiate” part is not needed when using the examples (only when the examples are implemented). Furthermore, there is a more simple approach: The ModiaMath/Project.toml file could include all packages that are used anywhere within ModiaMath (in scr, examples, test). In order to execute single examples or tests, the following commands would be needed:

]activate ModiaMath
import ModiaMath
include("$(ModiaMath.path)/examples/Simulate_Pendulum.jl")
]activate

Hm. This looks simple and clear enough (and could be documented in the README.md file).

You sure about that? I think this only worked because yiu happened to have all packages installed alread.

Sure, but that makes all those packages dependencies of ModiaMath which IIUC was what you wanted to avoid in the first place?

You sure about that? I think this only worked because yiu happened to have all packages installed alread.

Yes you are right.

Sure, but that makes all those packages dependencies of ModiaMath which IIUC was what you wanted to avoid in the first place?

I am still learning the new package manager and this was not clear to me.

Anyway, in current ModiaMath all extra packages used in examples and test are also present in src (with the only exception of package Test). So, in this case, this simplifed handling makes sense.

In the future this might change, especially in Modia where there will be examples from different domains (using different domain-specific model libraries not present in src) and then a Project.toml file (or Project.toml file per domain) under examples is probably a good solution.

You can think of Project.toml’s [deps] section as the old REQUIRE file.

I recognized that the approach with “activate …” works for packages that are added with dev, but not for packages that are added with add. E.g., if package ModiaMath is just used (and not developed), then ]add ModiaMath will make ModiaMath availalable in the actual environment, but activate ModiaMath will generate a new development version of ModiaMath in directory .julia/dev (so this approach seems to not work).

It seems my proposal above to reference extra packages and tests via the ModiaMath package is still the best workround (one could slightly improve it by adding a small explanation in the examples why, e.g. “using ModiaMath.StaticArrays” is used and not “using StaticArrays”).