Can't get `Preferences.set_preferences!()` to work

Hi folks,

I’m trying to use a custom binary with HiGHS.jl. I am following the instructions here: Custom binaries · JuMP

These instructions involve using Preferences.set_preferences!() to set the path to the custom binary. However, I can’t get this to work. Here is what I get:


julia> using HiGHS_jll

julia> HiGHS_jll.libhighs_path
"C:\\Users\\jodyd\\.julia\\artifacts\\bdd0d05b425c3feb2c354051d1fdad3210faa8ec\\bin\\libhighs.dll"

julia> using Preferences

julia> set_preferences!(
           "LocalPreferences.toml",
           "HiGHS_jll",
           "libhighs_path" => "C:\\Workspace\\Spine\\HiGHS\\build\\bin\\Release\\libhighs.dll"
       )

julia> exit()

C:\Users\jodyd>julia
               _
   _       _ _(_)_     |  Documentation: https://docs.julialang.org
  (_)     | (_) (_)    |
   _ _   _| |_  __ _   |  Type "?" for help, "]?" for Pkg help.
  | | | | | | |/ _` |  |
  | | |_| | | | (_| |  |  Version 1.6.3 (2021-09-23)
 _/ |\__'_|_|_|\__'_|  |  Official https://julialang.org/ release
|__/                   |

julia> using HiGHS_jll

julia> HiGHS_jll.libhighs_path
"C:\\Users\\jodyd\\.julia\\artifacts\\bdd0d05b425c3feb2c354051d1fdad3210faa8ec\\bin\\libhighs.dll"

So, it looks like set_preferences! isn’t doing what I’m expecting it to do or I am doing something wrong.

When I look in LocalPreferences.toml I see the expected content:

[HiGHS_jll]
libhighs_path = "C:\\Workspace\\Spine\\HiGHS\\build\\bin\\Release\\libhighs.dll"

I would be grateful for any assistance!

1 Like

Anyone any thoughts on this?

Feel free to tag me if it’s JuMP-related; I don’t read every post here :slight_smile: .

It seems I’m missing some crucial documentation.

I think LocalPreferences.toml needs to be in the same directory as your currently active Project.toml. So since you’ve just started in the global environment, it needs to be C:\\Users\\jodyd\\.julia\\environments\\v1.6\\LocalPreferences.toml.

I’d suggest you use a new local environment for this however, instead of overriding the global one.

1 Like