Skip to content

Preferences without a UUID mapping silently ignored in stacked environments #76

@topolarity

Description

@topolarity

In a stacked environment (just a local --project=. + the global env), Preferences will silently ignore LocalPreferences.toml entries if:

  1. The referenced package name is in a different stacked environment.
  2. The package where the Preference is coming from has no UUID mapping for the package name.
(@v1.10) pkg> status
Status `~/.julia/environments/v1.10/Project.toml`
⌅ [aea7be01] PrecompileTools v1.2.1

(@v1.10) pkg> activate .
  Activating project at `~/test-environments/rAI-Plots`

(rAI-Plots) pkg> status
Status `~/test-environments/rAI-Plots/Project.toml`
  [cd3eb016] HTTP v1.10.16
  [91a5bcdd] Plots v1.40.13
  [21216c6a] Preferences v1.4.3

shell> cat LocalPreferences.toml
[PrecompileTools]
precompile_workloads = false

julia> using Preferences
julia> Preferences.load_preference("PrecompileTools", "precompile_workloads", "no preference!")
"no preference!

If you try to load the package and do set_preference!(...), it will yell at you but it will also fix your bug:

julia> using PrecompileTools

julia> Preferences.set_preferences!("PrecompileTools", "precompile_workloads"=>"false")
ERROR: ArgumentError: Cannot set preference 'precompile_workloads' to 'false' for PrecompileTools in /home/topolarity/test-environments/rAI-Plots/LocalPreferences.toml: preference already set to 'false'!

julia> Preferences.load_preference("PrecompileTools", "precompile_workloads", "no preference!")
false

because this will add the missing [extras] entry to your Project.toml so that you have a UUID mapping for the preference:

shell> cat Project.toml
[deps]
HTTP = "cd3eb016-35fb-5094-929b-558a96fad6f3"
Plots = "91a5bcdd-55d7-5caf-9e0b-520d859cae80"
Preferences = "21216c6a-2e73-6563-6e65-726566657250"

[extras]
PrecompileTools = "aea7be01-6a6a-4083-8856-8a6e6704d82a"

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions