Confused about package loading

Agreed. I think you are correct here (assuming I understand your setup).

Again, if I understand your setup correctly, this is because:

  • Package Example is using package Dataframes

And yet:

  • Package Dataframes was not "add"ed to package Example’s project.toml file (dependency list).

Why does Julia treat these cases differently?

Considering the situation from your first example:

  • when using Dataframes is launched from the REPL.

Your current Julia session is clearly using an environment stack that defines Dataframes, so the session should be able to access this package.

On the other hand, in your second example:

  • using Dataframes is called from within package Example.

To Julia, this makes a huge difference. Julia wants to ensure all dependencies are clearly included in each package’s project.toml file.

If I were to guess, I would think this was done to ensure a smooth package installation experience in Julia:

  • By ensuring that all dependencies are present in the project.toml file, the package manager can correctly assume a package will work if all dependencies from project.toml are installed.

…Barring any mistakes in how the version compatibility ranges were specified (and other similar potential issues).

2 Likes