From 1faf240546ea17c19621e8e2b0b2f0824c966511 Mon Sep 17 00:00:00 2001
From: Michele Alberti <michele.alberti@cea.fr>
Date: Thu, 18 Mar 2021 16:30:52 +0100
Subject: [PATCH] Improve DIR error checking.

---
 solver.ml | 13 +++++++++----
 1 file changed, 9 insertions(+), 4 deletions(-)

diff --git a/solver.ml b/solver.ml
index b93fa9c..20feb3e 100644
--- a/solver.ml
+++ b/solver.ml
@@ -82,13 +82,18 @@ let exe_path_of_solver solver =
     end
   | Some dir ->
     (* The env variable should already provide the path to the executable: we
-       first check that the path is absolute, and then concatenate the [exe]
-       name to it. *)
+       first check that the path exists, refers to a directory and it is
+       absolute, then we concatenate the [exe] name to it. *)
+    if not (Sys.file_exists dir && Sys.is_directory dir)
+    then
+      Error (Format.sprintf "`%s' not exist or is not a directory." dir)
+    else
     if Filename.is_relative dir
     then
       Error
-        "Variable DIR is set with a relative path. \
-         An absolute path is required."
+        (Format.sprintf
+           "`%s' is a relative path. An absolute path is required for DIR."
+           dir)
     else
       let exe =
         if Filename.check_suffix dir Filename.dir_sep
-- 
GitLab