Skip to content

Current Dune alias syntax can't work reliably on Windows #5775

@jonahbeckford

Description

@jonahbeckford

Desired Behavior

I maintain the Diskuv OCaml distribution, and will be soon releasing a shim for Dune so that Windows users can just type dune build to build like everybody else does in *nix. The shim will bring a MSYS environment for any Unix binaries that a Dune project needs and will also bring MSVC so OCaml can do native compilation.

Unfortunately Dune aliases use the @ symbol. That means every Windows user who uses PowerShell (the default Windows shell in popular programs like Windows Terminal and VS Code) will be forced to escape any aliases. It sounds like a small problem, but it is a problem that will become a major complaint as more people use Windows on OCaml. So instead of:

dune build @foo

Windows users have to copy, paste and modify it to:

dune build `@foo

If they don't, the @ term can be silently removed because it is the PowerShell array operator. Have a look at:

$ echo dune build @foo
dune
build

$ echo dune build @foo/src/all
dune
build
@foo/src/all

Basically, the @foo array in PowerShell is acting like the ${foo[@]} array in Bash ... if the array variable does not exist it is empty.

Hopefully it is apparent how confusing or frustrating that will be to Windows Dune users, and time-consuming for any OCaml package maintainer who has to respond to bug reports why their dune command line does not work.

Proposed

Either of the following:

  1. Use dune build =foo or dune build +foo instead of dune build @foo.
  2. Use dune alias foo instead of dune build @foo.

In both cases I would remove dune build @foo from your documentation but keep that syntax around for backwards compatibility.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions