Skip to content

Commit

Permalink
Display a more understable error message in case the command to execu…
Browse files Browse the repository at this point in the history
…te by OPAM is not found in the path.

This should help debugging confusing errors such as ocaml#293.
  • Loading branch information
samoht committed Nov 12, 2012
1 parent 0754594 commit fa230f6
Showing 1 changed file with 10 additions and 4 deletions.
14 changes: 10 additions & 4 deletions src/core/opamSystem.ml
Expand Up @@ -263,10 +263,16 @@ let run_process ?verbose ?path ?(add_to_env=[]) ?(add_to_path=[]) = function
let verbose = match verbose with
| None -> !OpamGlobals.debug || !OpamGlobals.verbose
| Some b -> b in
let r = OpamProcess.run ~env ~name ~verbose cmd args in
if not !OpamGlobals.debug then
OpamProcess.clean_files r;
r
let cmd_exists =
OpamProcess.run ~env ~name:"command" ~verbose:false "command" ["-v";cmd] in
OpamProcess.clean_files cmd_exists;
if OpamProcess.is_success cmd_exists then (
let r = OpamProcess.run ~env ~name ~verbose cmd args in
if not !OpamGlobals.debug then
OpamProcess.clean_files r;
r
) else
OpamGlobals.error_and_exit "%S: command not found\n" cmd

let command ?verbose ?(add_to_env=[]) ?(add_to_path=[]) cmd =
let r = run_process ?verbose ~add_to_env ~add_to_path cmd in
Expand Down

0 comments on commit fa230f6

Please sign in to comment.