Skip to content

cmdstanr::cmdstanr_example() (or any other via brms) fails to compile via github Actions #1010

Open
@pcinereus

Description

@pcinereus

Describe the bug
I am trying to incorporate cmdstanr in a github actions workflow.
Parts of my workflow include:

      # install R
      - uses: r-lib/actions/setup-r@v2
        with:
          r-version: ${{ matrix.config.R }}

      - name: Repos
        run: |
          cat("\noptions(repos=c(stan='https://mc-stan.org/r-packages/',CRAN ='https://cloud.r-project.org'))\n", file = "~/.Rprofile", append = TRUE)
        shell: Rscript {0}
        
      ## Install R packages
      - name: install R packages
        uses: r-lib/actions/setup-r-dependencies@v2
        with:
          cache-version: 2
          packages: |
            stan-dev/cmdstanr
.....
      - name: Install CmdStan
          shell: Rscript {0}
          run: |
            cmdstanr::check_cmdstan_toolchain(fix = TRUE)
            cmdstanr::install_cmdstan(cores = parallel::detectCores())
            cmdstanr::cmdstanr_example()

The last line above was put in as a test to help track down an issue.

When I run this workflow, it runs without error. However, if I then install quarto and attempt to render a document:

    # install quarto
     - name: Install quarto
       uses: quarto-dev/quarto-actions/setup@v2
     - name: Change ImageMagick policy to allow pdf->png conversion.
       run: |
         sudo sed -i 's/^.*policy.*coder.*none.*PDF.*//' /etc/ImageMagick-6/policy.xml
      - name: Make tutorials
       run: |
         echo "library(quarto); quarto_render(\"index.qmd\")" | R --no-save --no-restore;

If that document includes an R chunk that includes cmdstanr::cmdstanr_example(), it fails with the following:

Error in `if (stancflags_local != "") ...`:
! the condition has length > 1
Backtrace:
 1. cmdstanr::cmdstanr_example()
 2. cmdstanr::cmdstan_model(tmp, force_recompile = force_recompile)
 3. CmdStanModel$new(...)
 4. cmdstanr (local) initialize(...)
 5. self$compile(...)

This error seems to be as a result of the call to cmdstanr:::get_cmdstan_flags("STANCFLAGS") returning a vector of strings when only a single string seems to be expected.
This what is returned:

[1] "make[2]:"                                        
[2] "Entering"                                        
[3] "directory"                                       
[4] "'/home/runner/.cmdstan/cmdstan-2.35.0'STANCFLAGS"
[5] "=make[2]:"                                       
[6] "Leaving"                                         
[7] "directory"                                       
[8] "'/home/runner/.cmdstan/cmdstan-2.35.0'"         

To Reproduce
See above

Expected behavior
The example model to be compiled

Operating system
Ubuntu via github actions

CmdStanR version number
2.35.0

Additional context
I realize that the above is not really a reproducible example, but I suspect that to some the issue might be very obvious. If not, I am happy to try to make a more minimum reproducible example

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