Different versions of same package in dependency graph

Suppose I create a project environment and add packages P1@2.0.0 and P2@2.0.0. And lets say P1@2.0.0 depends on P2@1.0.0. Does this create a conflict (like it does in Python)? Or will Julia take care of this and use P2@2.0.0 when I use it, and use P2@1.0.0 when P1@2.0.0 uses it?

It creates a conflict. You can only ever have one version of each package in an environment.

3 Likes

I have read that Julia handles packages with the same names with the mechanism above. Can’t that same mechanism be used to extend to different versions of the same package?

It is very inconvenient when you want to use an updated version of a package but can’t because one of your other dependencies doesn’t support it yet (at least in my experience with other languages, I am new to Julia).

Julia doesn’t allow you to have two dependencies with the same name, but it will notify you and make you choose which one to use at install time, if two registries host two different packages with the same name. A package is uniquely identified by its UUID, not its name.

In general, no, because you can’t differentiate structs based the version of a package they came from.

Imagine you have a third package, Q, which then would use P1@1 and P1@2. In the source code, you only have P1.my_struct - but there’s no way to specify that you want to create a my_struct from P1@1, not from P1@2. Worse, since the struct layout may have changed, even if you could create it, you wouldn’t be able to safely pass objects created from P1@1 to functions from P1@2, due to that difference in layout.

Fundamentally, that’s the reason you also get a conflict in python or with dynamic linking of shared libraries in C.

Maybe what you read is that Julia will handle multiple versions in the same depot, i.e. julia can have multiple versions stored on a local location on the disk? This allow for smooth handling of dependencies where multiple projects can depend on the same version, and then only a single one is stored on the disk, or different projects have different versions and then a single one of each needed version is stored on the disk.