Skip to content

Commit

Permalink
pkg: improve error message when curl not installed (#10403)
Browse files Browse the repository at this point in the history
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 <stephen@sherra.tt>
  • Loading branch information
gridbugs authored Apr 8, 2024
1 parent 3d03759 commit 1e51ffa
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 4 deletions.
9 changes: 5 additions & 4 deletions src/dune_pkg/fetch.ml
Original file line number Diff line number Diff line change
Expand Up @@ -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."
])
;;

Expand Down
26 changes: 26 additions & 0 deletions test/blackbox-tests/test-cases/pkg/curl-not-installed.t
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
Test the error message when curl is needed but not installed.

$ . ./helpers.sh
$ make_lockdir

$ makepkg() {
> make_lockpkg $1 <<EOF
> (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]

0 comments on commit 1e51ffa

Please sign in to comment.