actions
actions copied to clipboard
LoadLibrary failure on Windows when building package containing C++ using setup-renv
I'm sorry if this is off-topic, but I don't know where else to go.
Using setup-renv@v2 (see full yaml here), with a package from a GitHub repo containing C++ code that needs to be built (see lock file entry here), I get the following error message on Windows:
2022-07-13T13:43:33.6563486Z ##[error]Error: package or namespace load failed for 'CohortMethod' in inDL(x, as.logical(local), as.logical(now), ...):
2022-07-13T13:43:33.6565629Z unable to load shared object 'D:/a/CohortMethodModule/CohortMethodModule/renv/staging/1/00LOCK-CohortMethod/00new/CohortMethod/libs/x64/CohortMethod.dll':
2022-07-13T13:43:33.6566615Z LoadLibrary failure: The specified procedure could not be found.
(See full log here)
The package in question builds fine using setup-renv
on Linux and MacOS. Also, the package builds fine on Windows outside of renv in GitHub Actions (see relevant GitHub Actions logs here), and the package builds fine on local Windows machines with and without renv. It is also the only package containing C++ code in the renv lock file that needs to be built, so it is likely the error is not specific to that package, just to packages containing C++.
So the failure is specific to
- packages containing C++, on
- Windows, when using
- setup-renv via
- GitHub Actions
Any other combination the build works fine.
Any suggestions of how to solve this would be greatly appreciated.
A shot in the dark, try using Rtools42, see the options here: https://github.com/r-lib/actions/tree/v2-branch/setup-r#inputs
He shoots.. he scores!
Thanks! Setting `rtools-version: '42' fixed the issue. For completeness, here's the relevant entry in my yaml:
- uses: r-lib/actions/setup-r@v2
with:
r-version: ${{ matrix.config.r }}
rtools-version: '42'
I'm surprised it didn't already pick RTools42 for R4.2.1 though. I'll leave the issue open if you want to dig into that. Feel free to close otherwise.
We don't install Rtools42 by default because Rtools40 is already installed on the VM and it takes a long time to install Rtools42.
Rtools40 usually works, except if you build a package from source, and the package has some system dependencies. If your package is such, then another fix would be to install these manually before setup-r-dependencies
.
This issue has been automatically locked. If you believe you have found a related problem, please file a new issue and include a link to this issue