Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Making it possible to set preferences for a non-installed package? #53

Open
oschulz opened this issue May 25, 2023 · 0 comments
Open

Making it possible to set preferences for a non-installed package? #53

oschulz opened this issue May 25, 2023 · 0 comments
Labels
enhancement New feature or request

Comments

@oschulz
Copy link

oschulz commented May 25, 2023

This came up in the context of CUDA.jl:

JuliaGPU/CUDA.jl#1922 (comment)

To use a non-artifact/system-wide CUDA installation, the "official" way it to use

CUDA.set_runtime_version!("local")

but that results in a multi-GB download of the CUDA runtime artifacts, only to then switch to not using them. As an alternative, one can use

Preferences.set_preferences!(CUDA_Runtime_jll, "version" => "local")

But to do that, CUDA_Runtime_jll needs to be loaded first - since it's a low-level package, it's much better of in the [extras] section of the current project then in it's direct dependencies. But it its now a direct dependency, it can't be loaded directly, so we don't have access to the CUDA_Runtime_jll object. But what about using the UUID of CUDA_Runtime_jll? That'll would do the trick:

Preferences.set_preferences!(Base.UUID("76a88914-d11a-5bdc-97e0-2f5a05c973a2"), "version" => "local")

it's set's the preference and would add CUDA_Runtime_jll to [extras] automatically. But it's not that easy because what happens is

julia> Preferences.set_preferences!(Base.UUID("76a88914-d11a-5bdc-97e0-2f5a05c973a2"), "version" => "local")
ERROR: Cannot set preferences of an unknown package that is not loaded!

It does work, however, if CUDA_Runtime_jll is already in the [extras] section of the current project. So it's a bit of a chicken-and-egg problem, and the only way seems to be adding CUDA_Runtime_jll to [extras] manually. That makes it hard to provide simple set-up commands/scripts for systems to users, especially if they don't have much Julia experience yet (tutorial scenarios, etc.). Unfortunately there seems to be no user-accessible functionality in Pkg that adds a dependency to [extras] instead of [deps].

Maybe we could add allow

Preferences.set_preferences!("CUDA_Runtime_jll", "version" => "local")

as well? It could warn that the package hasn't been installed yet and add it to [extras] (and set the preference(s), of course).

Or maybe this is already possible in some other way with Preferences?

CC @vchuravy

@oschulz oschulz changed the title Making it possible to set a preference for a non-installed package? Making it possible to set preferences for a non-installed package? May 25, 2023
@vchuravy vchuravy added the enhancement New feature or request label May 25, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants