-
Notifications
You must be signed in to change notification settings - Fork 19
Description
Following the method documented here https://juliadiff.org/ForwardDiff.jl/stable/user/advanced/#Fixing-NaN/Inf-Issues aiming to set preferences before loading a package, gives the following error:
(@v1.11) pkg> activate --temp
Activating new project at `/var/folders/yq/4p2zwd614y59gszh7y9ypyhh0000gn/T/jl_g5YtBV`
julia> using Preferences, UUIDs
julia> set_preferences!(UUID("f6369f11-7733-5829-9624-2563aa707210"), "nansafe_mode" => true)
ERROR: Cannot set preferences of an unknown package that is not loaded!
Stacktrace:
[1] error(s::String)
@ Base ./error.jl:35
[2] set_preferences!(u::UUID, prefs::Pair{String, Bool}; export_prefs::Bool, active_project_only::Bool, kwargs::@Kwargs{})
@ Preferences ~/.julia/packages/Preferences/enLcN/src/Preferences.jl:281
[3] set_preferences!(u::UUID, prefs::Pair{String, Bool})
@ Preferences ~/.julia/packages/Preferences/enLcN/src/Preferences.jl:223
[4] top-level scope
@ REPL[3]:1
julia> using ForwardDiff
julia> sqrt(ForwardDiff.Dual(0.0, 0.0))
Dual{Nothing}(0.0,NaN)Same error with a string, which literally contains what needs to be written to LocalPreferences.toml, no need to look up UUIDs:
(@v1.11) pkg> activate --temp
Activating new project at `/var/folders/yq/4p2zwd614y59gszh7y9ypyhh0000gn/T/jl_VyTFmo`
julia> using Preferences
julia> set_preferences!("ForwardDiff", "nansafe_mode" => true)
ERROR: Cannot set preferences of an unknown package that is not loaded!I'm not sure you regard this as a bug, but something like this seems the obvious way to try out some preference option with a package. By "try out" I mean I want a temporary environment so that I'm sure it is not making any changes globally which I'll have to figure out how to reverse later. I think that loading the package and then calling set_preferences!(ForwardDiff, "nansafe_mode" => true) can't do that, as it needs a restart, and then I will get a new temporary environment.
Is there a way? Can it be documented somewhere easy to find?