-
Notifications
You must be signed in to change notification settings - Fork 437
Looking up paths to executables with dune which #11905
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
base: main
Are you sure you want to change the base?
Conversation
Here's an example session using this command:
|
a574375
to
6e42f8b
Compare
Is this essentially |
It is, yes, but I bet a lot of people don't know you can expand pforms like that (for example I did not know this). |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think it is a very cool feature. In fact, I would actually suggest making a dune which
top level command, as dune exec --which
is a flag I will immediately forget and it is fairly obscure and does not actually execute the command.
6e42f8b
to
e143dff
Compare
Updated this so that the command is now |
f59a49b
to
985c96c
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Except for some minor cleanup I think this is nearly done. I really like the cram test!
Maybe this should go under |
Why is the expected frequency with which a command will be used a useful metric for deciding whether to put it at the top level or not? I think it belongs at the top level because I expect this command to be used by people debugging a situation where dune ran a command they didn't expect, and for this use case it's important that the command be easy to discover. |
3cac659
to
63981ae
Compare
The "dune exec" command has three different ways of resolving the names of executables to paths to executables: - public executables defined in the current project - executables in the "bin" directories of dependencies - executables in directories listed in $PATH This can lead to unexpected shadowing, especially in the case of executables from dependecies, as users may not be aware that one of the packages in their project's dependency cone defines an executable with the same name of an executable that's also insalled system-wide. Short of fixing the problem for now, this change introduces a tool for helping investigate specifically which executable will be run by "dune exec". This adds a command "dune which" which prints the path to the executable. Signed-off-by: Stephen Sherratt <[email protected]>
63981ae
to
79e5ff2
Compare
There are other commands under The point of having a hierarchical command line is to make the commands more discoverable. If putting things under sub-commands made the CLI less discoverable, why did we introduce the hierarchy in the first place? Dune is not like git where sub-commands are their own binaries, so it was done for purely organizational purposes. IMO, the underlying issue is that the "discoverability" of one command comes at the expense of other commands. So yes, you have made Now it could be that I'm underestimating the utility of this command, and it is going to be more useful than I'm imagning - I'll leave the decision where to put it up to you. But I do want to clarify that:
Is the principle we should be following. We hide scarcely used commands, and promote the ones that are often used. We group related sub-commands to avoid repeating prefixes. We optimize for the common case. |
$ chmod a+x bin/baz | ||
$ export PATH=$PWD/bin:$PATH | ||
|
||
$ dune which baz |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could you add a test for dune which %{..}
? I think it should support this.
For what it's worth, something like |
The "dune exec" command has three different ways of resolving the names of executables to paths to executables:
This can lead to unexpected shadowing, especially in the case of executables from dependecies, as users may not be aware that one of the packages in their project's dependency cone defines an executable with the same name of an executable that's also insalled system-wide.
Short of fixing the problem for now, this change introduces a tool for helping investigate specifically which executable will be run by "dune exec". This adds a command "dune which" which prints the path to the executable.