-
Notifications
You must be signed in to change notification settings - Fork 15
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
Global preferences #33
Comments
Global preferences essentially work through the JULIA_LOAD_PATH. See https://juliaparallel.org/tutorials/preferences/#interactions_with_the_julia_load_path |
Yeah, you'll need to provide a global entry on the |
Just checking – any way to have global (machine/depot wide) preferences now? :) |
What I do a lot (on different HPC clusters where I want global preferences) is to save a
Note that the colon after the equal sign is crucial as it means "append". This works very well for me. See https://juliahpc.github.io/sysadmin_julia/#providing_global_package_preferences. |
|
That's unfortunate, indeed. Although I would argue that setting environment variables is a pretty canonical way to set global settings (well beyond Julia) and would therefore see this as more of a Pluto or (And, to be fair, both Pluto and |
Julia environments carry a lot more than preferences – most notably, packages. Naturally, tests and notebooks don't want other packages (not under their control) to influence the setup, so they don't propagate LOAD_PATH. I assume this is an explicit decision, not an oversight.
So there's indeed no way to set Preferences globally. Tests and notebooks are common, these aren't some niche usecases. |
I could also imagine a |
I just want to say that Pluto is precisely the context where I'd like to be able to set global preferences for a computer / user account. |
Are there any issues with adding |
What if my depot isn't under the default path (in home)? Also, communicating this information through a file at a fixed place isn't optimal. It's fragile (the user might wipe the depot at some point) and non trivial (when/how should the sys admin create this file? It's much easier to set an environment variable). If we would choose this "global fixed file" approach, I'd probably (in addition) want a |
Sorry for ambiguity, I meant
And that's fine, isn't it? Wipe the depot => the entire Julia installation is removed, including its settings.
The presence of a global preferences file doesn't preclude adding env vars for preferences, or to customize the location of this file for complex setups. I'm just saying there should be a way to put the global preferences file somewhere so that it's read by default no matter how Julia is started. The vast majority of computers are effectively single-user, so "truly global" and "user-global" are typically the same. |
I think we should entangle two things here. The first point is:
I think it's fair to ask for a way to load preferences from The second point is: How should it be possible to specify the location of these
The advantage of 1) is that it is simple. The disadvantage of 1), at least in its current form, is that it doesn't give "truly global" but only "user depot global" preferences, which can be an issue in some scenarios (e.g. multi-user server settings like HPC). However, this could be amended by including a fixed location The advantage of 2) is that it is more flexible. The disadvantage is that Pluto and |
Oh, I didn't even know it's not possible :) So, setting a Preference for a package is currently not allowed without having the package installed in the same env? Sorry for these basic questions, didn't really play with preferences after I understood that there's no support for global. |
I misspoke a little bit and have updated my post above. It is possible to create a However, loading preferences and making packages loadable (i.e. Note that a tangent to this is that it would be nice to have public API here that allows one to access available preferences for a package that is not a |
So we have a way of defining "global" preferences most of the time... But not all the time. Yikes! I wanted to bump this here by providing an example: on our system (NERSC Perlmutter), it is essential that the system version of MPI and CUDA are used. To this end we also do what @carstenbauer does and set "global" preferences via JULIA_LOAD_PATH. Worse, the jll version of CUDA does not necessarily result in a crash, but just wrong behavior. So this leads to the frustrating situation where you develop some code, and everything works as expected (because Julia is using the JULIA_LOAD_PATH in most circumstances)... And then PKG.test() fails... With the same damned code. What are we going to do about this? It's important that the solution is something the sysadmin can do (as we have a lot of users, most of which don't read the docs) |
When preferences were first added, we originally did not have any preference merging across load path [0]. We later added that [1], but retained the requirement that for each individual element in the load path, preferences must have an entry in `Project.toml` listing the relevant package. This was partly on purpose (immediately binding the name to the UUID prevents confusion when a UUID<->name binding is not readily apparent) and partly just inheriting the way things worked back when preferences was written with just a single Project.toml in mind. This PR breaks this assumption to specifically allow an entry in the Julia load path that contains only a single `LocalPreferences.toml` file that sets preferences for packages that may or may not be in the current environment stack. The usecase and desire for this is well-motivated in [2], but basically boils down to "system admin provided preferences that should be used globally". In fact, one such convenient method that now works is to drop a `LocalPreferences.toml` file in the `stdlib` directory of your Julia distribution, as that is almost always a part of a Julia process's load path. [0] #37595 [1] #38044 [2] JuliaPackaging/Preferences.jl#33
I think it's clear that the current behavior is not what we want, so I have just made a PR that at least fixes the fundamental problem, I think: JuliaLang/julia#56575 With that PR you should be able to have preferences that refer to packages that are not a top-level dependency in your current project (but that exist within a Manifest somewhere in your load path). This means that you can now have preferences applied to non-top-level deps, but also that you can have a |
How to make global preferences for a package? I tried putting them to
~/.julia/environments/v1.7/Project.toml
, but they are only available when this environment is in the LOAD_PATH. Code running from tests or from Pluto notebooks doesn't have this load path entry, so those preferences are unavailable.I'm talking about machine-specific preferences, like some system directory path, or hardware-related settings. They seem to be a good fit for Preferences.jl, but such preferences should always be available in order to make sense at all.
The text was updated successfully, but these errors were encountered: