BARON - ERROR: IOError: could not spawn

I am solving a non-linear optimization problem using BARON. The BARON.jl package version I am using is 0.6.2 and it seems to be working fine. But after I update the package to 0.6.3 or 0.6.4, following error is displayed:

ERROR: IOError: could not spawn `Caroaron.exe 'C:\Users\Dell\AppData\Local\Temp\jl_ldhYWv\baron_problem.bar'`: no such file or directory (ENOENT)

Any suggestions on how to resolve this error?

The path to the BARON executable seems garbled (Caroaron.exe). Can you rebuild the BARON package and check that the contents of deps/path.jl make sense? You will need to have set the BARON_EXEC environment variable.

1 Like

I rebuild the package and the content of deps/path.jl is const baron_exec = "C:\baron\baron.exe"
BARON_EXEC environment variable is also set as follows:
image

Same error pops even after rebuilding the package.

You probably want C:\\baron\\baron.exe or C:/baron/baron.exe.

1 Like

Oops, looks like this is my fault: https://github.com/joehuchette/BARON.jl/blob/f227a61d6038643f9b06224f68b60f11fda79e7b/deps/build.jl#L8, with write it only writes the single slash

C:\\baron\\baron.exe or C:/baron/baron.exe indeed works. Thank you @odow and @joehuchette!

Hi Eric,

Is this the reason why C:\baron\baron.exe was working perfectly uptil now? Also, my environment variables for some other packages (e.g. CPLEX) are set using ‘\’ and they seems to be working perfectly fine. (I am on a windows machine).

Maybe you were on an older version of Baron.jl? The change is fairly recent. The problem isn’t the environmental variables, it’s that they get written to a file in a way that messes up the slashes on Windows. I submitted a PR to fix it, so it should get fixed in the library soon (https://github.com/joehuchette/BARON.jl/pull/43), but just adding the / to the deps/path.jl file should work too.

(edit: at least I think so! not totally confident with how the paths work on Windows…)

1 Like

Got it! Thanks :+1:

1 Like

The latest tagged version should have a fix, if you want to give it an update.

1 Like

Thank you for the quick fix!

I get a similar error
Base.IOError(“could not spawn C:\baron\baron.exe 'C:\\Users\\rtapi\\AppData\\Local\\Temp\\jl_DdCLHT\\baron_problem.bar': no such file or directory (ENOENT)”, -4058)

After defining the env variable: ENV[“BARON_EXEC”]=“C:/baron/baron.exe”

Try: ENV["BARON_EXEC"]="C:\\baron\\baron.exe"

To double check: you’ve downloaded BARON and obtained a license, and that is the location of where you saved it?

I’ve tried every slash combination, would Julia automatically update the environment? Should it show up in my windows environment variables?

Yes, I double checked its directory.

Do you have a reproducible example?

What is the output of this:

ENV["BARON_EXEC"] = "C:\\baron\\baron.exe"
import Pkg
Pkg.add("BARON")
Pkg.build("BARON")
Pkg.status()
versioninfo()

Then in a new Julia session:

using JuMP
using BARON
model = Model(BARON.Optimizer)
@variable(model, 0 <= x <= 10, Int)
@objective(model, Min, (x - 4)^2)
optimize!(model)

That worked thanks!

which command updates the ENV?

output:
“C:\baron\baron.exe”
complied except i had some MySQL dependency issue which I am yet to figure out.

[2e2ca445] BARON v0.8.2
[fbb218c0] BSON v0.3.9
[6e4b80f9] BenchmarkTools v1.5.0
[a076750e] CPLEX v1.0.3
[336ed68f] CSV v0.10.12
[13f3f980] CairoMakie v0.11.9
[49dc2e85] Calculus v0.5.1
[e2554f3b] Clp v1.0.3
[8f4d0f93] Conda v1.10.0
[a93c6f00] DataFrames v1.6.1
[31c24e10] Distributions v0.25.107
[becb17da] Feather v0.5.10
[5789e2e9] FileIO v1.16.2
[f6369f11] ForwardDiff v0.10.36
[60bf3e95] GLPK v1.1.3
[2e9cd046] Gurobi v1.2.1
[cd3eb016] HTTP v1.10.2
[7073ff75] IJulia v1.24.2
[b6b21f68] Ipopt v1.6.2
[033835bb] JLD2 v0.4.46
[682c06a0] JSON v0.21.4
[4076af6c] JuMP v1.20.0
[ee78f7c6] Makie v0.20.8
[39abe10b] MySQL v1.4.5
[a15396b6] OnlineStats v1.6.3
[429524aa] Optim v1.9.2
[91a5bcdd] Plots v1.40.1
[c46f51b8] ProfileView v1.7.2
[438e738f] PyCall v1.96.4
[d330b81b] PyPlot v2.11.2
[6f49c342] RCall v0.14.1
[295af30f] Revise v3.5.14
[3646fa90] ScikitLearn v0.7.0
⌅ [2913bbd2] StatsBase v0.33.21
[f3b207a7] StatsPlots v0.15.7
[69024149] StringEncodings v0.3.7
[61d0e4fa] Taro v0.8.5
[770da0de] UpdateJulia v0.4.4
[fdbf4ff8] XLSX v0.10.1

Julia Version 1.10.1
Commit 7790d6f064 (2024-02-13 20:41 UTC)

ENV is a dictionary in your local Julia session. We don’t modify the global Windows environment variables, you’d need to do that manually.

But you only need the ENV["BARON_EXEC"] set when you add or update BARON.jl.

I think the problem was that you must have done Pkg.add("BARON") without setting the environment variable, and then subsequent add didn’t trigger Pkg.build.

The MySQL error seems unrelated to JuMP or BARON, perhaps open a new post if you can’t figure it out.