Skip to content

Commit

Permalink
fix: suggest setting --prefix on empty install
Browse files Browse the repository at this point in the history
When a user has not set --prefix they will get a confusing error message
about mandir. The suggestion here is to also set --mandir leading them
down a rabbit hole of specifying a complete install layout. What they
probably want to be doing is speciying --prefix so we change the error
message here to suggest that instead.

fix #7814

Signed-off-by: Ali Caglayan <alizter@gmail.com>
  • Loading branch information
Alizter authored and rgrinberg committed Jun 19, 2023
1 parent e9db492 commit fa448e2
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 2 deletions.
6 changes: 5 additions & 1 deletion bin/install_uninstall.ml
Original file line number Diff line number Diff line change
Expand Up @@ -45,9 +45,13 @@ let get_dirs context ~prefix_from_command_line ~from_command_line =
match v with
| Some v -> v
| None ->
(* We suggest that the user sets --prefix first rather than the specific
missing option, since this is the most common case. *)
User_error.raise
[ Pp.textf "The %s installation directory is unknown." name ]
~hints:[ Pp.textf "It could be specified with --%s" name ]
~hints:
[ Pp.textf "It can be specified with --prefix or by setting --%s" name
]
in
{ Roots.lib_root = must_be_defined "libdir" roots.lib_root
; libexec_root = must_be_defined "libexecdir" roots.libexec_root
Expand Down
3 changes: 2 additions & 1 deletion test/blackbox-tests/test-cases/install/install-no-prefix.t
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,8 @@ Here we specify the behaviour of dune install when no install prefix is given.

We should suggest to the user here that they should use --prefix.

$ unset OPAM_SWITCH_PREFIX
$ dune install
Error: The mandir installation directory is unknown.
Hint: It could be specified with --mandir
Hint: It can be specified with --prefix or by setting --mandir
[1]

0 comments on commit fa448e2

Please sign in to comment.