ocaml / ocaml/dune

[RFC] Use `dune shell` for testing failing command

Open
#3,961 9 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

accepted proposal
Dominant language
OCaml
Stars
1.9k
Forks
500
Avg merge
15h 21m
Merged PRs (30d)
277

Description

When an action fails we currently print a little sh script which should run the command in the same way:

(cd _build/default/foo/bar && ../my.exe arg1 arg2 > file1 )

However we have to go to great length to translate some action features such as redirection, pipe, that we are not always sure to translate correctly. Moreover dune adds also a lot of environment variables such as OCAML_LOADPATH, and also dune specific one for the sites and plugin mechanism. So running executable directly from _build is a bad habit and will fail in not simple cases.

dune exec execute correctly executable with the needed environment. We can perhaps make it able to execute actions so that the output of failed command is simpler to write and more truthful but still easy to modify from the command line:

dune exec --in-build-dir --chdir foo/bar --context default --with-stdout-to file1 -- ../my.exe arg1 arg2

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by tracing how failed actions are rendered into shell scripts and how dune exec handles --in-build-dir, --chdir, --context, and output redirection. Compare the current failure command with the proposed dune exec form; done means failed commands can be reproduced with the needed Dune environment without manually translating action features.

Written by the indexing model from the issue text.

Assessment

Tech stack
ocaml
Domain
build-system, cli
Issue type
Feature
Difficulty
5/5
Estimated time
Over a week
Activity status
Active
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.