diff --git a/solver.ml b/solver.ml
index b93fa9c049d0b9a12d74c40804e49b79f37c43c3..20feb3e2c33e788f593c90fcf2668b9a9f4a126f 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