Is it necessary to install all the packages listed in REQUIRE or Project.toml of a package?


In general, in Julia, if I add a package A through a URL from github, do I have to also install all the packages listed in the REQUIRE (or maybe Project.toml) of A, in order to use A normally?

It seems that for some A, I can still use it even if I don’t install all the other REQUIRE packages by myself. But I have also seen cases where I have to install the exact versions of the packages stated in REQUIRE in order to use the original package.

I would appreciate it if someone could explain how this works.


REQUIRE is deprecated.

If you install a package on a recent Julia version, it will install compatible versions as given by the bounds from Project.toml automatically, so that you can use the added package.

However, you will only be able to using packages you added, you won’t be able to using those dependencies.

If a package is unregistered, it could be that it’s list of required packages is broken. You could file an issue asking them to fix it, or a PR fixing it yourself.
Some unregistered packages depend on other unregistered packages, meaning those dependencies can’t be installed automatically.


Actually, you can do

using Foo.Bar

where Bar is a dependency package.



You don’t even need to specify where Bar is used. Just using Bar will work.


Thank you. Are you saying as long as the dependencies of a package are registered, they will be installed automatically when I add the package?

Technically, as being in a registry you have added is sufficient — in practice, for most people this is the General registry.

Actually just using Bar did not work for me. I had to do the using Foo.Bar version for the dependency package, otherwise I got the error ArgumentError: Package BioSequences not found in current path:. The same result with both using and import.

I was trying to use BioSequences package that was a dependancy of BioAlignments, hence I did not explicitly add the package

If you require BioSequences yourself, you can just add it anyway - it will not be downloaded or duplicated again, as it has already been loaded by BioAlignments. Only one version of a package will be loaded at any given time. Also makes the intent clearer for people looking at your project later on, since ]st will show that you do indeed require BioSequences. It will also be robust against BioAlignments choosing not to use BioSequences in the future (unlikely, but possible).

Ah, I see. Definitely makes sense to add it in case the dependency is removed. Thank you for the explanation!