From 1cbea5a8c32f4b0abd2d2f2af4127eacebdaaae7 Mon Sep 17 00:00:00 2001 From: Stephen Sherratt Date: Mon, 8 Apr 2024 16:32:14 +1000 Subject: [PATCH] pkg: improve error message when curl not installed Adds a hint and some details to the error message when curl is needed by dune but not installed. Also changes the formatting of "curl" in the error message to not use dune's formatting for commands, as it is the name of a program and not a command. Signed-off-by: Stephen Sherratt --- src/dune_pkg/fetch.ml | 9 ++++--- .../test-cases/pkg/curl-not-installed.t | 26 +++++++++++++++++++ 2 files changed, 31 insertions(+), 4 deletions(-) create mode 100644 test/blackbox-tests/test-cases/pkg/curl-not-installed.t diff --git a/src/dune_pkg/fetch.ml b/src/dune_pkg/fetch.ml index 54e109c74ad..f2383a6de22 100644 --- a/src/dune_pkg/fetch.ml +++ b/src/dune_pkg/fetch.ml @@ -8,10 +8,11 @@ module Curl = struct | Some p -> p | None -> User_error.raise - [ Pp.concat - ~sep:Pp.space - [ User_message.command "curl"; Pp.text "not available in PATH" ] - |> Pp.hovbox + ~hints:[ Pp.text "Install curl with your system package manager." ] + [ Pp.text + "The program \"curl\" does not appear to be installed. Dune uses curl to \ + download packages. Dune requires that the \"curl\" executable be located \ + in one of the directories listed in the PATH variable." ]) ;; diff --git a/test/blackbox-tests/test-cases/pkg/curl-not-installed.t b/test/blackbox-tests/test-cases/pkg/curl-not-installed.t new file mode 100644 index 00000000000..04ee39b4dc0 --- /dev/null +++ b/test/blackbox-tests/test-cases/pkg/curl-not-installed.t @@ -0,0 +1,26 @@ +Test the error message when curl is needed but not installed. + + $ . ./helpers.sh + $ make_lockdir + + $ makepkg() { + > make_lockpkg $1 < (source + > (fetch + > (url "http://0.0.0.0:8000"))) + > (version dev) + > EOF + > } + + $ makepkg foo + +Build the package in an environment without curl. + $ PATH=$(dirname $(which dune)) build_pkg foo + File "dune.lock/foo.pkg", line 3, characters 7-28: + 3 | (url "http://0.0.0.0:8000"))) + ^^^^^^^^^^^^^^^^^^^^^ + Error: The program "curl" does not appear to be installed. Dune uses curl to + download packages. Dune requires that the "curl" executable be located in one + of the directories listed in the PATH variable. + Hint: Install curl with your system package manager. + [1]