Cygport Bug: "find: No such file" Errors When Packaging

William Hu purplearmadillo77@proton.me
Thu Sep 15 19:38:04 GMT 2022


Hello,

I think I've found a (relatively innocuous) bug in cygport. It can be reproduced 
by compiling the OCaml package without having OCaml installed (which doesn't 
sound like an unreasonable thing to try; it'd be odd if OCaml depended on 
itself). This results in many unattractive errors at the end of the `cygport 
package` stage when cygport searches for dependencies:

*** Info: Tagging package hint files as test:
find: ‘/usr/lib/ocaml’: No such file or directory
find: ‘/usr/lib/ocaml’: No such file or directory
>>> ocaml requires: cygwin libgcc1 flexdll ocaml-runtime
find: ‘/usr/lib/ocaml’: No such file or directory
find: ‘/usr/lib/ocaml’: No such file or directory
>>> ocaml-runtime requires: cygwin libgcc1
find: ‘/usr/lib/ocaml’: No such file or directory
find: ‘/usr/lib/ocaml’: No such file or directory
>>> ocaml-compiler-libs requires: ocaml-runtime ocaml
find: ‘/usr/lib/ocaml’: No such file or directory
find: ‘/usr/lib/ocaml’: No such file or directory
>>> ocaml-ocamldoc requires: cygwin libgcc1 ocaml-compiler-libs ocaml-runtime
find: ‘/usr/lib/ocaml’: No such file or directory
find: ‘/usr/lib/ocaml’: No such file or directory
>>> ocaml-source requires:
find: ‘/usr/lib/ocaml’: No such file or directory
find: ‘/usr/lib/ocaml’: No such file or directory
>>> ocaml-doc requires:

Looking at cygport's code 
<https://github.com/cygwin/cygport/blob/8407994126516d73aeb17b6b829578c0848a4c4d/lib/pkg_info.cygpart#L364>
 it seems cygport checks for the existence of ocamlc.opt on PATH. Because the 
(package being built)'s install directory is appended to PATH by cygport, this 
will always be true in my case.

OCaml's compilers hardcode their location at compile time, so ocamlc.opt believes 
the standard library lives in "/usr/lib/ocaml" which is placed in `mldir`.

Cygport checks one more time to make sure mldir exists in the package being built 
(this second check is why those errors are hard to trigger on a non-OCaml package) 
and then calls `find` on both ${D}${mldir} and ${mldir}. Of course, since the 
*real* /usr/lib/ocaml won't exist if OCaml isn't installed on your actual system 
when you build it, find will output an error when run on those two directories.

Two ways to fix this would be to either remove the ${mldir} argument from find or 
test if ${mldir} exists and set it to the empty string if it doesn't. The second 
would likely preserve compatibility if there exist packages that depend on find 
searching both directories. The buggy test was added in 
<https://github.com/cygwin/cygport/commit/7d24eb71bdd91e2a368739728dbd522ddd4faaac>. 
Does anyone else have any insights or suggestions or does the above fix sound
reasonable?

Thanks,
William



More information about the Cygwin-apps mailing list