oasis icon indicating copy to clipboard operation
oasis copied to clipboard

oasis should use bash on windows whenever possible (cmd as fallback)

Open gildor478 opened this issue 4 years ago • 0 comments

This feature request has been migrated from artifact #1229 on forge.ocamlcore.org. It was assigned to user102.

user8328 posted on 2012-10-26 14:28:15:

During porting several godi packages to windows, I've encountered various issues with packages that use oasis.

There are two main problems:

  • oasis doesn't quote parameteres passed to external command ( or quotes them in a wrong way)
  • oasis use cmd.exe (via Sys.command)

cmd.exe has several disadvantages:

  • cmd.exe can't execute PostConfCommand and similar instructions in the _oasis files (at least in most cases)
  • there are also path in _oasis and other locations with *nix path separators. cmd.exe can't deal with them properly. (It's a problem of cmd.exe, windows itself excepts both, '/' and '', as path separator)
  • the command line length is restricted (~8000), the quoting of arguments is problematic.

Calling bash.exe / sh.exe (msys/cygwin) instead would solve the first and last poinst:

  • bash could execute most PostConfCommands
  • the command line length limit is less restricted (only the limits imposed by CreateProcess)

However, there are also disadvantages:

  • Some (but not all) utils of cygwin have problems with windows path separators (paths like 'C:/cygwin/tmp/test.dat' seem to work)
  • bash is not installed by default ( currently not an issue. Users have to install msys or cygwin in any case - because of ocamlbuild )

For testing purpose, I've modified some files (see https://github.com/arirux/oasis )

  • OASISExec now uses bash, if bash and other unix tools are found in $PATH.
  • I've introduced OASISHostPath.quote. Filename.quote can't be used any longer, because bash requires different quoting.
  • I've rewritten OASISHostPath.of_unix. If "/" is enforced as path separators for bash and "" for cmd.exe, there a less problems with quoting.

I've tested the changes with following packages that use oasis:

godi-batteries godi-benchmark godi-cfg godi-ocaml-data-notation godi-ocaml-expect godi-ocaml-fileutils godi-ocaml-text godi-ounit godi-pomap godi-res godi-sexplib godi-sqlite3 godi-type_conv godi-xmlm

There are still problems, because OASISHostPath.quote and OASISHostPath.of_unix are not always used, where they should be used. But beside of this, all package now compile cleanly with bash AND cmd. Before the changes, they couldn't be installed at all, only partially (installing files with ocamlfind usually worked, copying documentation and similar files not) , and/or it was depending on a right combination of forward/backward slashes in various command-line switches and environment variables like OCAMLLIB.

user102 replied on 2012-10-26 16:35:46:

Here is my point of view:

  1. try to avoid a strong dependencies on bash, we should target at avoiding it for Windows user
  2. provide it as a compat layer through a command line flag, like "--use-bash cmd", so that it will allow people to get out of problematic situation, but still be able to use cmd.exe in most of the case
  3. the "best" options will be to be able to detect the most common problem directly when we compile _oasis -> setup.ml, i.e. make sure everything is well quoted for both Windows and UNIX. I don't know to what extent this is possible but it would be a very nice feature to have.
  4. the "ultra top" options is to have a "sh" interpreter directly into the setup.ml (is it possible ?)

But overall thanks a lot for the patch, please send a pull request with at least 1. and 2. so that we can talk about implementation. Point 3. and 4. are nice to have, but only if you want to invest time on it.

gildor478 avatar Oct 24 '20 16:10 gildor478