Skip to content

Display a warning when dune builds via RPC #11833

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 5 commits into
base: main
Choose a base branch
from

Conversation

gridbugs
Copy link
Collaborator

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.

@gridbugs gridbugs force-pushed the dune-build-via-rpc-warning branch from 48478fc to 14c8b1b Compare May 22, 2025 06:29
@maiste maiste added the build Issue related to what dune build label May 22, 2025
@gridbugs gridbugs force-pushed the dune-build-via-rpc-warning branch from 14c8b1b to 9c96729 Compare May 23, 2025 03:03
Warning: A running dune (pid: 124305) instance has locked the build
directory. If this is not the case, please delete "_build/.lock".
The requested targets will still be built however functionality will be
reduced and some command line arguments will be ignored.
Copy link
Collaborator

Choose a reason for hiding this comment

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

A couple of questions:

  • "If this is not the case, please delete ..." is this relevant ? if the build is being forwarded to a running instance, it doesn't make much sense to me to ask the user to delete the lock file.
  • "functionality will be reduced" what does this refer to?

I suggest tweaking the message and making it a bit less scary:

Warning: your build request is being forwarded to a running Dune instance (pid: 124305). Note that certain command line arguments may be ignored.

Copy link
Collaborator

@Leonidas-from-XIV Leonidas-from-XIV left a comment

Choose a reason for hiding this comment

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

I like the idea of warning the user when flags get ignored, but I would suggest that this would only happen if there are flags that will get discarded.

@gridbugs gridbugs force-pushed the dune-build-via-rpc-warning branch 2 times, most recently from 8fa6b9f to 2c531a3 Compare May 26, 2025 09:14
@gridbugs
Copy link
Collaborator Author

Updated so that it only prints the warning if extra arguments were passed to dune build. This is done by comparing the Builder.t parsed from command-line arguments to the default Builder.t that would be created if no arguments were passed. This has become a fairly big change because I needed to propagate equal functions throughout the code, and I needed to change how Log.File.t is defined so that it can be tested for equality.

I also added Term.eval_no_args for extracting the default value of a type by running its command-line argument parser with no input which is possibly a controversial way of getting a default value, but I think otherwise computing a default value of a Builder.t would require quite a big refactor.

@gridbugs gridbugs force-pushed the dune-build-via-rpc-warning branch 3 times, most recently from f39d3aa to 7d09871 Compare May 27, 2025 06:22
Copy link
Collaborator

@Leonidas-from-XIV Leonidas-from-XIV left a comment

Choose a reason for hiding this comment

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

It's a bit sad all these very verbose equal functions need to be added but I understand the idea.

Overall I think it needs a small wording change and an additional test and then it is good to go.

bin/build_cmd.ml Outdated
User_warning.emit
[ Pp.textf
"Your build request is being forwarded to a running Dune instance%s. \
Note that certain command line arguments may be ignored."
Copy link
Collaborator

Choose a reason for hiding this comment

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

Since this warning is now only emitted when arguments have been ignored, I think it should state that command line arguments have in fact been ignored.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Not all arguments are ignored though. The Builder module is perhaps poorly named, as Builder.term takes care of parsing arguments like --verbose and --display which still take effect when dune is behaving as an rpc client. I'll still think about how to reword this message to be more helpful though.

Copy link
Collaborator

Choose a reason for hiding this comment

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

But if I understand it correctly at this point the Builder instance is unequal to one without arguments, thus at this point we know for a fact that arguments have been ignored? Or do I misunderstand the logic of this PR?

gridbugs added 5 commits May 28, 2025 13:22
The only [out_channel] that was ever passed in was stderr. Removing the
[Out_channel] case allows us to more easily test [Log.File.t] for
equality.

Signed-off-by: Stephen Sherratt <[email protected]>
Signed-off-by: Stephen Sherratt <[email protected]>
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]>
@gridbugs gridbugs force-pushed the dune-build-via-rpc-warning branch from 7d09871 to 0741bbc Compare May 28, 2025 03:22
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
build Issue related to what dune build
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants