Skip to content

Commit 25f5d93

Browse files
committed
Display a warning when dune builds via RPC
When an instance of dune is already running, invoking `dune build` will still build the target, howwever other command line arguments are silently ignored by dune as the current RPC interface is too limited to express them. This may change over time, but currently it's unusual UX for `dune build` to behave differently depending on whether or not another instance of `dune build` is already running. To more accurately set user expectations, print a warning when dune is running with this reduced functionality. Signed-off-by: Stephen Sherratt <[email protected]>
1 parent f3e6325 commit 25f5d93

2 files changed

Lines changed: 18 additions & 0 deletions

File tree

bin/build_cmd.ml

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -215,6 +215,16 @@ let build =
215215
perform the RPC call.
216216
*)
217217
Scheduler.go_without_rpc_server ~common ~config (fun () ->
218+
if not (Common.Builder.equal builder Common.Builder.default)
219+
then
220+
User_warning.emit
221+
[ Pp.textf
222+
"Your build request is being forwarded to a running Dune instance%s so \
223+
most command-line arguments will be ignored."
224+
(match (lock_held_by : Dune_util.Global_lock.Lock_held_by.t) with
225+
| Unknown -> ""
226+
| Pid_from_lockfile pid -> sprintf " (pid: %d)" pid)
227+
];
218228
build_via_rpc_server ~print_on_success:true ~targets)
219229
| Ok () ->
220230
let request setup =

test/blackbox-tests/test-cases/watching/watching-eager-concurrent-build-command.t

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ Build the project once before starting the watch server so the watch server star
99
$ dune build --watch &
1010
Success, waiting for filesystem changes...
1111
Success, waiting for filesystem changes...
12+
Success, waiting for filesystem changes...
1213
File "foo.ml", line 1, characters 9-21:
1314
1 | let () = print_endlin "Hello, World!"
1415
^^^^^^^^^^^^
@@ -26,6 +27,13 @@ Demonstrate that we can run "dune build" while the watch server is running.
2627
$ dune build
2728
Success
2829

30+
Demonstrate that a warning is displayed when extra arguments are passed to
31+
"dune build", since those arguments will be ignored.
32+
$ dune build --auto-promote 2>&1 | sed 's/pid: [0-9]*/pid: PID/g'
33+
Warning: Your build request is being forwarded to a running Dune instance
34+
(pid: PID) so most command-line arguments will be ignored.
35+
Success
36+
2937
Demonstrate that error messages are still printed by "dune build" when it's
3038
acting as an RPC client while running concurrently with an RPC server.
3139
$ echo 'let () = print_endlin "Hello, World!"' > foo.ml

0 commit comments

Comments
 (0)