Can't install rstan and run rcmdcheck in github actions

Hi,

I have a package running Github actions that depends on rstan and is giving me some headaches to install on Windows. There are two problems.

First, rstan has a bug when combined with the latest withr package (2.3.0). That is, if I install the CRAN rstan with the CRAN withr, some of my models throw weird errors. They're aware of that and they've fixed it their dev branch. To fix this, they suggest to roll back to withr 2.2.0 and just continue as is. The issue is that if I roll back to withr 2.2.0, rcmdcheck fails with:

rcmdcheck::rcmdcheck(args = c("--no-manual"), error_on = "warning", check_dir = "check")
-- R CMD build -----------------------------------------------------------------
Error in withr::local_envvar(R_MAKEVARS_USER = private$makevars_file) : 
  unused argument (R_MAKEVARS_USER = private$makevars_file)
Calls: <Anonymous> ... with_envvar -> force -> <Anonymous> -> initialize -> rcb_init
Execution halted

You can see the GH actions logs here for this problem but I can also replicated this on a local Windows machine.

The solution I thought was to just download the development version of rstan from Github, on which they say they've fixed the problem with withr. The second problem is that if I try to install the development rstan, it doesn't install successfully for reasons I can't understand:

remotes::install_github("stan-dev/rstan", ref = "develop", subdir = "rstan/rstan", build_opts = "")
Using github PAT from envvar GITHUB_PAT
Downloading GitHub repo stan-dev/rstan@develop
stan-dev-rstan-2f29681/StanHeaders/inst/include/libsundials: Can't create '\\\\?\\C:\\Users\\RUNNER~1\\AppData\\Local\\Temp\\RtmpcnR6A8\\remotes1764732549d8\\stan-dev-rstan-2f29681\\StanHeaders\\inst\\include\\libsundials'
stan-dev-rstan-2f29681/StanHeaders/inst/include/src: Can't create '\\\\?\\C:\\Users\\RUNNER~1\\AppData\\Local\\Temp\\RtmpcnR6A8\\remotes1764732549d8\\stan-dev-rstan-2f29681\\StanHeaders\\inst\\include\\src'
stan-dev-rstan-2f29681/StanHeaders/inst/include/stan: Can't create '\\\\?\\C:\\Users\\RUNNER~1\\AppData\\Local\\Temp\\RtmpcnR6A8\\remotes1764732549d8\\stan-dev-rstan-2f29681\\StanHeaders\\inst\\include\\stan'
tar.exe: Error exit delayed from previous errors.
"C:\PROGRA~1\Git\bin\git.exe" clone --depth 1 --no-hardlinks --recurse-submodules --branch develop https://github.com/stan-dev/stan.git C:\Users\RUNNER~1\AppData\Local\Temp\RtmpcnR6A8\remotes1764732549d8/stan-dev-rstan-2f29681/rstan/rstan/../../StanHeaders/inst/include/upstream
Cloning into 'C:\Users\RUNNER~1\AppData\Local\Temp\RtmpcnR6A8\remotes1764732549d8/stan-dev-rstan-2f29681/rstan/rstan/../../StanHeaders/inst/include/upstream'...
Updating files:  43% (1023/2355)
Updating files:  44% (1037/2355)
Updating files:  45% (1060/2355)
Updating files:  46% (1084/2355)
Updating files:  47% (1107/2355)
Updating files:  48% (1131/2355)
Updating files:  49% (1154/2355)
Updating files:  50% (1178/2355)
Updating files:  51% (1202/2355)
Updating files:  52% (1225/2355)
Updating files:  53% (1249/2355)
Updating files:  54% (1272/2355)
Updating files:  55% (1296/2355)
Updating files:  56% (1319/2355)
Updating files:  57% (1343/2355)
Updating files:  58% (1366/2355)
Updating files:  59% (1390/2355)
error: unable to create file src/test/test-models/good/function-signatures/distributions/univariate/continuous/double_exponential/double_exponential_ccdf_log.stan: Filename too long
error: unable to create file src/test/test-models/good/function-signatures/distributions/univariate/continuous/double_exponential/double_exponential_cdf_log.stan: Filename too long
Updating files:  60% (1413/2355)
Updating files:  61% (1437/2355)
Updating files:  62% (1461/2355)
Updating files:  63% (1484/2355)
Updating files:  64% (1508/2355)
error: unable to create file src/test/test-models/good/function-signatures/distributions/univariate/continuous/scaled_inv_chi_square/scaled_inv_chi_square_ccdf_log.stan: Filename too long
error: unable to create file src/test/test-models/good/function-signatures/distributions/univariate/continuous/scaled_inv_chi_square/scaled_inv_chi_square_cdf.stan: Filename too long
error: unable to create file src/test/test-models/good/function-signatures/distributions/univariate/continuous/scaled_inv_chi_square/scaled_inv_chi_square_cdf_log.stan: Filename too long
error: unable to create file src/test/test-models/good/function-signatures/distributions/univariate/continuous/scaled_inv_chi_square/scaled_inv_chi_square_log.stan: Filename too long
Updating files:  65% (1531/2355)
Updating files:  66% (1555/2355)
Updating files:  67% (1578/2355)
Updating files:  68% (1602/2355)
Updating files:  69% (1625/2355)
Updating files:  70% (1649/2355)
Updating files:  71% (1673/2355)
Updating files:  72% (1696/2355)
Updating files:  73% (1720/2355)
Updating files:  74% (1743/2355)
Updating files:  75% (1767/2355)
Updating files:  76% (1790/2355)
Updating files:  77% (1814/2355)
Updating files:  78% (1837/2355)
Updating files:  79% (1861/2355)
Updating files:  80% (1884/2355)
Updating files:  81% (1908/2355)
Updating files:  82% (1932/2355)
Updating files:  83% (1955/2355)
Updating files:  84% (1979/2355)
Updating files:  85% (2002/2355)
Updating files:  86% (2026/2355)
Updating files:  87% (2049/2355)
Updating files:  88% (2073/2355)
Updating files:  89% (2096/2355)
Updating files:  89% (2111/2355)
Updating files:  90% (2120/2355)
Updating files:  91% (2144/2355)
Updating files:  92% (2167/2355)
Updating files:  93% (2191/2355)
Updating files:  94% (2214/2355)
Updating files:  95% (2238/2355)
Updating files:  96% (2261/2355)
Updating files:  97% (2285/2355)
Updating files:  98% (2308/2355)
Updating files:  99% (2332/2355)
Updating files: 100% (2355/2355)
Updating files: 100% (2355/2355), done.
fatal: unable to checkout working tree
warning: Clone succeeded, but checkout failed.
You can inspect what was checked out with 'git status'
and retry with 'git restore --source=HEAD :/'

Error: Error: Failed to install 'rstan' from GitHub:
  Command failed (128)
In addition: Warning messages:
1: In utils::untar(tarfile, ...) :
  'tar.exe -xf "C:\Users\RUNNER~1\AppData\Local\Temp\RtmpcnR6A8\file17646566ecc.tar.gz" -C "C:/Users/RUNNER~1/AppData/Local/Temp/RtmpcnR6A8/remotes1764732549d8"' returned error code 1
2: In system(full, intern = TRUE, ignore.stderr = quiet) :
  running command '"C:\PROGRA~1\Git\bin\git.exe" clone --depth 1 --no-hardlinks --recurse-submodules --branch develop https://github.com/stan-dev/stan.git C:\Users\RUNNER~1\AppData\Local\Temp\RtmpcnR6A8\remotes1764732549d8/stan-dev-rstan-2f29681/rstan/rstan/../../StanHeaders/inst/include/upstream' had status 128
Execution halted

Here are the GH actions logs and I can also reproduce this problem locally on a Windows machine.

I've made sure to follow the instructions for updating the Makesvars files from the dev rstan although these instructions are not necessary for installing the CRAN rstan and is installed successfully in the withr error when rolling back to 2.2.0.

Does anyone know what's going on? Any pointers on how to fix this?

The CRAN version of rstan is failing with the latest withr because withr versions prior to 2.3.0 silently swallowed errors in the cleanup code. withr 2.3.0 now throws an error if any of the cleanup steps has an error. It seems the CRAN version of rstan has a bug in the cleanup code (possibly only on windows).

The devel version of rstan 'fixes' this by removing withr.

You are getting an error running rcmdcheck::rcmdcheck() because pkgbuild() uses a withr 2.3.0 feature, though it did not update this properly in the DESCRIPTION`. I have fixed that in r-lib/pkgbuild@2aaecf8.

If you want to use withr 2.2.0 you will have to run R CMD build . && R CMD check *tar.gz manually, rather than using the rcmdcheck package.

I would encourage the rstan developers to submit a new version of their package to CRAN soon, rather than suggesting users use these workarounds.

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.

If you have a query related to it or one of the replies, start a new topic and refer back with a link.