Pkg: dependency 'features'


we’ve developed a library-type package that is easily extendable by users of this library with extensions. We’d like to provide users several standard extensions, but each of these extensions comes with a cost (uncompression lib, git library, S3 lib, GCP lib, etc.). We don’t want to burden the users app with all these possibly unnessary dependencies. Rust’s package manager (crate) has something they call feature Rust crate feature exactly for this use case. Julia’s pkg mgr doesn’t have any such feature, correct? Am I right to assume that with Julia we need to put each extension into a separate package respectively git repo, and in the documentation we need to point users to the already existing extensions?

thanks a lot

There is GitHub - JuliaPackaging/Preferences.jl: Project Preferences Package and while it cannot change the dependencies that gets downloaded, it can be used to change what packages you actually end up loading.

I think that Requires.jl may be also relevant here.


I’m not able to install Preferences?!?! I can pkg add it, but it errors on using it. Error message is that TOMLCache is missing. I tried to pkg add it, but pkg manager cannot find it. Searching the internet, doesn’t find it either. Jira issue seem to allude that it is available in julia 1.6 but may be not earlier? I’m using Julia 1.5.3 (win10). If that is the case, shouldn’t pkg mgr fail to add Preferences, if not min Julia 1.6 is used?

julia> using Preferences
[ Info: Precompiling Preferences [21216c6a-2e73-6563-6e65-726566657250]
ERROR: LoadError: UndefVarError: TOMLCache not defined
 [1] include(::Function, ::Module, ::String) at .\Base.jl:380
 [2] include(::Module, ::String) at .\Base.jl:368
 [3] top-level scope at none:2
 [4] eval at .\boot.jl:331 [inlined]
 [5] eval(::Expr) at .\client.jl:467
 [6] top-level scope at .\none:3
in expression starting at C:\Users\jdonnerstag\.julia\packages\Preferences\BbvxU\src\Preferences.jl:4
ERROR: Failed to precompile Preferences [21216c6a-2e73-6563-6e65-726566657250] to C:\Users\jdonnerstag\.julia\compiled\v1.5\Preferences\pWSk8_JLjYb.ji.
 [1] error(::String) at .\error.jl:33
 [2] compilecache(::Base.PkgId, ::String) at .\loading.jl:1305
 [3] _require(::Base.PkgId) at .\loading.jl:1030
 [4] require(::Base.PkgId) at .\loading.jl:928
 [5] require(::Module, ::Symbol) at .\loading.jl:923

(FileRepo) pkg> add TOMLCache
   Updating registry at `C:\Users\jdonnerstag\.julia\registries\General`
   Updating git-repo ``
ERROR: The following package names could not be resolved:
 * TOMLCache (not found in project, manifest or registry)

The package claims to be compatible with 1.6 but that apparently seems to be a twist of the truth.

Sorry, not sure I understand your comment.

My own Project.toml has
julia = “1.5”

The (latest on github) Preferences project.toml says
julia = “1.0”

And I’m using Julia 1.5.3 (win10). To me it seems that Preferences’ compat should be 1.6 as it depends on TOMLCache which seems only be in Base since 1.6

Yes, that is precisely correct.

1 Like