Skip to content

Include paths for Make are hand-quoted rather than properly escaped #1230

Description

@jgabry

A path containing a single quote, e.g. Jonah's includes, results in messed up shell syntax. Affects include_paths_stanc3_args(), not direct stanc calls since those pass the paths unquoted.

d <- file.path(tempdir(), "Jonah's includes")
dir.create(d)
cmdstan_model("model.stan", include_paths = d)

Additional context

When I asked Claude about this bug after I ran into it, it made these extra comments, which seem relevant.

Two things a fix needs to handle:

  • shQuote() on the comma-separated value fixes the shell layer only. The value is
    passed as STANCFLAGS += ... and expanded by Make first, so a path containing $
    breaks before any shell sees it.
  • On Windows the Make shell is conditional — SHELL = sh.exe is set only when sh
    is on PATH — so shQuote() would need an explicit type = "sh" rather than R's
    platform default.

For the space-only case shQuote(type = "sh") produces exactly the current output,
so the common path is unchanged by such a fix.

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions