Usability/Documentation issues with copy_files/glob
Nobody has claimed this yet.
- Dominant language
- OCaml
- Stars
- 1.9k
- Forks
- 500
- Avg merge
- 15h 21m
- Merged PRs (30d)
- 277
Description
Expected Behavior
-
copy_filesdoes not warn if the<glob>expression matches a directory instead of a file. It would be very useful to report such errors, in the same way as the Cannot copy files onto themselves message already does for files in the local directory.
Currently, if the user mistakenly uses a directory name (or even the name of a non-existing file), dune silently does nothing, without reporting any errors. -
It is unclear to me why
(copy_files (glob_files_rec <glob>))does not work. Thecopy_filesdocumentation mentions:<glob>represents the set of files to copy. See the glob for details.That page, in turn, mentions:
Dune supports globbing files in a single directory via
(glob_files ...)and, starting with Dune 3.0, in all sub-directories recursively via(glob_files_rec ...).I then assumed that
<glob>in thecopy_filespart could be replaced with(glob_files ...). So I tried using(copy_files (files (glob_files_rec ../dir/*))), but it complains withError: Unexpected list. If I remove thefilespart, since thecopy_filesdoc mentions that The short form(copy_files <glob>)is equivalent to(copy_files (files <glob>)), it then complains withError: field files missing.
In both cases, I am unable to combinecopy_fileswithglob_files, which seems it should be possible from the documentation. The lack of usage examples for this option makes it harder to understand how it must be written.
Actual Behavior
- No errors reported in case of non-existing/directory name
- Error when trying to combine
copy_filesandglob_files; lack of usage examples.
Reproduction
First issue:
cd /tmp && dune init project projcd projmkdir d; touch cecho "(copy_files ../d)" >> bin/dune# user meant "../c" instead of "../d"echo "(copy_files ../invalid)" >> bin/dune# user entered a non-existing pathdune build
No error/warning is emitted; no files are copied.
Second issue:
echo "(copy_files (glob_files_rec ../d/*))" >> bin/dune# documentation suggests it might workdune build# error- Erase erroneous line from
bin/dune echo "(copy_files (files (glob_files_rec ../d/*)))" >> bin/dune# documentation suggests it might workdune build# another error
Also, there are no examples with glob_files_rec.
Specifications
- Version of
dune(output ofdune --version): 3.3.1 - Version of
ocaml(output ofocamlc --version): 4.08.1 - Operating system (distribution and version): Linux Fedora 36
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start by reproducing the two cases in bin/dune with copy_files, glob_files, and glob_files_rec, then read the copy_files and glob documentation linked in the report. Confirm the intended behavior for directory or missing matches and the valid syntax for recursive globs. Done means the behavior is clearly diagnosed or reported, and the documentation includes accurate usage examples.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- ocaml
- Domain
- build-system, documentation
- Issue type
- Documentation
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100