Skip to content

Commit

Permalink
If BARON executable is not located, we now defer crashing until you t…
Browse files Browse the repository at this point in the history
…ry to actually solve a model. Previously, it crashed when loading the package; you now get a warning instead.
  • Loading branch information
joehuchette committed Jun 8, 2020
1 parent 1ff662e commit 373a2eb
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 2 deletions.
6 changes: 4 additions & 2 deletions src/BARON.jl
Original file line number Diff line number Diff line change
@@ -1,10 +1,12 @@
module BARON

try
const IS_SOLVER_SET = try
include(joinpath(@__DIR__, "..", "deps", "path.jl"))
true
catch
error("""BARON.jl was not built correctly.
@warn("""BARON.jl was not built correctly.
Set the environment variable `BARON_EXEC` and run `using Pkg; Pkg.build("BARON")`.""")
false
end

mutable struct VariableInfo
Expand Down
4 changes: 4 additions & 0 deletions src/MOI_wrapper.jl
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,10 @@ end

# optimize
function MOI.optimize!(model::Optimizer)
if !IS_SOLVER_SET
error(("""BARON.jl was not built correctly.
Set the environment variable `BARON_EXEC` and run `using Pkg; Pkg.build("BARON")`."""))
end
write_bar_file(model.inner)
run(`$baron_exec $(model.inner.problem_file_name)`)
read_results(model.inner)
Expand Down

2 comments on commit 373a2eb

@joehuchette
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@JuliaRegistrator
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Registration pull request updated: JuliaRegistries/General/16017

After the above pull request is merged, it is recommended that a tag is created on this repository for the registered package version.

This will be done automatically if the Julia TagBot GitHub Action is installed, or can be done manually through the github interface, or via:

git tag -a v0.6.3 -m "<description of version>" 373a2eb496281aae72b75e972b5f1ccc78eefce6
git push origin v0.6.3

Please sign in to comment.