# BARON - ERROR: IOError: could not spawn

**URL:** <https://discourse.julialang.org/t/baron-error-ioerror-could-not-spawn/44430>\
**Category:** Optimization (Mathematical)\
**Tags:** question, package\
**Created:** [August 6, 2020, 4:27pm UTC](https://discourse.julialang.org/t/baron-error-ioerror-could-not-spawn/44430 "2020-08-06T16:27:20Z")\
**Posts on this page:** 17\
**Page:** 1

<div class="post-metadata">

**Author:** ![trathi](https://avatars.discourse-cdn.com/v4/letter/t/7c8e57/32.png) [@trathi](https://discourse.julialang.org/u/trathi)\
**Post date:** [August 6, 2020, 4:27pm UTC](https://discourse.julialang.org/t/baron-error-ioerror-could-not-spawn/44430/1 "2020-08-06T16:27:20Z")

</div>

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:

```julia
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?

---

<div class="post-metadata">

**Author:** ![joehuchette](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/joehuchette/32/32_2.png) [@joehuchette](https://discourse.julialang.org/u/joehuchette)\
**Post date:** [August 6, 2020, 4:46pm UTC](https://discourse.julialang.org/t/baron-error-ioerror-could-not-spawn/44430/2 "2020-08-06T16:46:15Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![trathi](https://avatars.discourse-cdn.com/v4/letter/t/7c8e57/32.png) [@trathi](https://discourse.julialang.org/u/trathi)\
**Post date:** [August 6, 2020, 5:21pm UTC](https://discourse.julialang.org/t/baron-error-ioerror-could-not-spawn/44430/3 "2020-08-06T17:21:50Z")

</div>

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](https://global.discourse-cdn.com/julialang/original/3X/5/9/59df3683b24736e774b775acf2debc608445bd2c.png)

Same error pops even after rebuilding the package.

---

<div class="post-metadata">

**Author:** ![odow](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/odow/32/28685_2.png) [@odow](https://discourse.julialang.org/u/odow)\
**Post date:** [August 6, 2020, 6:43pm UTC](https://discourse.julialang.org/t/baron-error-ioerror-could-not-spawn/44430/4 "2020-08-06T18:43:52Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![ericphanson](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/ericphanson/32/215186_2.png) [@ericphanson](https://discourse.julialang.org/u/ericphanson)\
**Post date:** [August 6, 2020, 7:25pm UTC](https://discourse.julialang.org/t/baron-error-ioerror-could-not-spawn/44430/5 "2020-08-06T19:25:33Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![trathi](https://avatars.discourse-cdn.com/v4/letter/t/7c8e57/32.png) [@trathi](https://discourse.julialang.org/u/trathi)\
**Post date:** [August 6, 2020, 7:28pm UTC](https://discourse.julialang.org/t/baron-error-ioerror-could-not-spawn/44430/6 "2020-08-06T19:28:26Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![trathi](https://avatars.discourse-cdn.com/v4/letter/t/7c8e57/32.png) [@trathi](https://discourse.julialang.org/u/trathi)\
**Post date:** [August 6, 2020, 7:30pm UTC](https://discourse.julialang.org/t/baron-error-ioerror-could-not-spawn/44430/7 "2020-08-06T19:30:22Z")

</div>

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).

---

<div class="post-metadata">

**Author:** ![ericphanson](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/ericphanson/32/215186_2.png) [@ericphanson](https://discourse.julialang.org/u/ericphanson)\
**Post date:** [August 6, 2020, 7:32pm UTC](https://discourse.julialang.org/t/baron-error-ioerror-could-not-spawn/44430/8 "2020-08-06T19:32:53Z")

</div>

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](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…)

---

<div class="post-metadata">

**Author:** ![trathi](https://avatars.discourse-cdn.com/v4/letter/t/7c8e57/32.png) [@trathi](https://discourse.julialang.org/u/trathi)\
**Post date:** [August 6, 2020, 7:36pm UTC](https://discourse.julialang.org/t/baron-error-ioerror-could-not-spawn/44430/9 "2020-08-06T19:36:22Z")

</div>

Got it! Thanks 👍

---

<div class="post-metadata">

**Author:** ![joehuchette](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/joehuchette/32/32_2.png) [@joehuchette](https://discourse.julialang.org/u/joehuchette)\
**Post date:** [August 6, 2020, 9:12pm UTC](https://discourse.julialang.org/t/baron-error-ioerror-could-not-spawn/44430/10 "2020-08-06T21:12:13Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![trathi](https://avatars.discourse-cdn.com/v4/letter/t/7c8e57/32.png) [@trathi](https://discourse.julialang.org/u/trathi)\
**Post date:** [August 6, 2020, 10:40pm UTC](https://discourse.julialang.org/t/baron-error-ioerror-could-not-spawn/44430/11 "2020-08-06T22:40:24Z")

</div>

Thank you for the quick fix!

---

<div class="post-metadata">

**Author:** ![rtapia](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/rtapia/32/207390_2.png) [@rtapia](https://discourse.julialang.org/u/rtapia)\
**Post date:** [March 1, 2024, 1:08am UTC](https://discourse.julialang.org/t/baron-error-ioerror-could-not-spawn/44430/12 "2024-03-01T01:08:20Z")

</div>

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”

---

<div class="post-metadata">

**Author:** ![odow](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/odow/32/28685_2.png) [@odow](https://discourse.julialang.org/u/odow)\
**Post date:** [March 1, 2024, 1:31am UTC](https://discourse.julialang.org/t/baron-error-ioerror-could-not-spawn/44430/13 "2024-03-01T01:31:12Z")

</div>

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?

---

<div class="post-metadata">

**Author:** ![rtapia](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/rtapia/32/207390_2.png) [@rtapia](https://discourse.julialang.org/u/rtapia)\
**Post date:** [March 1, 2024, 2:21am UTC](https://discourse.julialang.org/t/baron-error-ioerror-could-not-spawn/44430/14 "2024-03-01T02:21:24Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![odow](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/odow/32/28685_2.png) [@odow](https://discourse.julialang.org/u/odow)\
**Post date:** [March 1, 2024, 2:32am UTC](https://discourse.julialang.org/t/baron-error-ioerror-could-not-spawn/44430/15 "2024-03-01T02:32:29Z")

</div>

Do you have a reproducible example?

What is the output of this:

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

```

Then in a new Julia session:

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

```

---

<div class="post-metadata">

**Author:** ![rtapia](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/rtapia/32/207390_2.png) [@rtapia](https://discourse.julialang.org/u/rtapia)\
**Post date:** [March 1, 2024, 4:10am UTC](https://discourse.julialang.org/t/baron-error-ioerror-could-not-spawn/44430/16 "2024-03-01T04:10:33Z")

</div>

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)

---

<div class="post-metadata">

**Author:** ![odow](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/odow/32/28685_2.png) [@odow](https://discourse.julialang.org/u/odow)\
**Post date:** [March 1, 2024, 8:05am UTC](https://discourse.julialang.org/t/baron-error-ioerror-could-not-spawn/44430/17 "2024-03-01T08:05:59Z")

</div>

`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.
