Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions src/dune_rules/run_with_path.ml
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ let depexts_hint = function
; Pp.enumerate ~f:Pp.verbatim depexts
]
|> Pp.concat_map ~sep:Pp.cut ~f:(fun pp -> Pp.box pp)
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This should be ~f:Fun.id and you should put Pp.hovbox on the first line and Pp.vbox on the second. Then you should do a Pp.vbox after concatenating. I think this will give you what you want.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I assume you mean:

let depexts_hint = function
  | [] -> None
  | depexts ->
    [ Pp.hovbox @@ Pp.textf "You may want to verify the following depexts are installed:"
    ; Pp.vbox @@ Pp.enumerate ~f:Pp.verbatim depexts
    ]
    |> Pp.concat_map ~sep:Pp.cut ~f:Fun.id
    |> Pp.vbox
    |> Option.some
;;

I tried that and it had the same behaviour as the current state of this PR.

|> Pp.vbox
|> Option.some
;;

Expand Down
58 changes: 57 additions & 1 deletion test/blackbox-tests/test-cases/pkg/depexts/error-message.t
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,8 @@ error message.
File "dune-project", line 1, characters 0-0:
Error: Invalid first line, expected: (lang <lang> <version>)

Hint: You may want to verify the following depexts are installed:
Hint:
You may want to verify the following depexts are installed:
- gnupg
- unzip
[1]
Expand Down Expand Up @@ -76,3 +77,58 @@ when the program is not found.
Hint: You may want to verify the following depexts are installed:
- unknown-package
[1]

Update the foo lockfile to have a single depext name:
$ make_lockpkg foo <<EOF
> (version 0.0.1)
> (build
> (run dune build))
> (depexts foo)
> (source
> (fetch
> (url file://$PWD/foo.tar)
> (checksum md5=$(md5sum foo.tar | cut -f1 -d' '))))
> EOF

Build the project, when it fails building 'foo' package, it shows the depexts
error message.
$ dune build
File "dune.lock/foo.pkg", line 3, characters 6-10:
3 | (run dune build))
^^^^
Error: Logs for package foo
File "dune-project", line 1, characters 0-0:
Error: Invalid first line, expected: (lang <lang> <version>)

Hint: You may want to verify the following depexts are installed:
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Shouldn't this be updated too with the new line?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ideally yes but I haven't figured out how to express this with Pp. The algorithm that Pp uses for formatting breaks lines in such a way that it breaks between Hint: and the message depending on the length of the message. In this case it splits if the concatenation of all depext names is longer than some threshold even though the depext names are in a vbox so their total width shouldn't matter (only their maximum width).

It might be a bug in Pp though I don't completely understand Pp.

- foo
[1]


Update the foo lockfile to have short depext names:
$ make_lockpkg foo <<EOF
> (version 0.0.1)
> (build
> (run dune build))
> (depexts a b)
> (source
> (fetch
> (url file://$PWD/foo.tar)
> (checksum md5=$(md5sum foo.tar | cut -f1 -d' '))))
> EOF

Build the project, when it fails building 'foo' package, it shows the depexts
error message.
$ dune build
File "dune.lock/foo.pkg", line 3, characters 6-10:
3 | (run dune build))
^^^^
Error: Logs for package foo
File "dune-project", line 1, characters 0-0:
Error: Invalid first line, expected: (lang <lang> <version>)

Hint: You may want to verify the following depexts are installed:
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Shouldn't this be updated too with the new line?

- a
- b
[1]

Loading