stringfish icon indicating copy to clipboard operation
stringfish copied to clipboard

Error when installing stringfish in R/4.4.0

Open robin-sto opened this issue 1 year ago • 2 comments

Hello, I am running into an issue when installing via install.packages("stringfish", type="source", configure.args="--with-simd=AVX2"):

** R ** inst ** byte-compile and prepare package for lazy loading ** help *** installing help indices ** building package indices ** installing vignettes ** testing if installed package can be loaded from temporary location Error: package or namespace load failed for ‘stringfish’ in dyn.load(file, DLLpath = DLLpath, ...): unable to load shared object '/root/R/x86_64-pc-linux-gnu-library/4.4/00LOCK-stringfish/00new/stringfish/libs/stringfish.so': /root/R/x86_64-pc-linux-gnu-library/4.4/00LOCK-stringfish/00new/stringfish/libs/stringfish.so: undefined symbol: ZN2sf19pcre2_match_wrapperC1ERKS0 Error: loading failed Execution halted ERROR: loading failed

  • removing ‘/root/R/x86_64-pc-linux-gnu-library/4.4/stringfish’

The downloaded source packages are in ‘/tmp/RtmpWKQ1NE/downloaded_packages’ Warning message: In install.packages("stringfish", type = "source", configure.args = "--with-simd=AVX2") : installation of package ‘stringfish’ had non-zero exit status

robin-sto avatar May 17 '24 19:05 robin-sto

Hello, would need some more to go on. Is it possible to make this issue reproducible in a docker/VM?

traversc avatar May 21 '24 18:05 traversc

I was also having errors installing stringfish on R4.4.x, but updating Rcpp (and RcppParallel) first solved them

dvg-p4 avatar Aug 22 '24 19:08 dvg-p4

Updating Rcpp also worked for me.

The default Rcpp on Ubuntu (installed with apt-get from https://cloud.r-project.org/bin/linux/ubuntu jammy-cran40) is 1.0.8 (checked with Rcpp::getRcppVersion()) make a following error:

/usr/lib/R/site-library/Rcpp/include/Rcpp/print.h: In function ‘void Rcpp::warningcall(SEXP, const string&)’:
/usr/lib/R/site-library/Rcpp/include/Rcpp/print.h:30:19: error: format not a string literal and no format arguments [-Werror=format-security]
   30 |     Rf_warningcall(call, s.c_str());
      |     ~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~
cc1plus: some warnings being treated as errors
make: *** [/usr/lib/R/etc/Makeconf:204: RcppExports.o] Error 1

Updating to Rcpp 1.0.13 (with install.packages("Rcpp") and without explicit deleting of apt package) resolved the problem and qs finally was installed.

nsimakov avatar Sep 08 '24 16:09 nsimakov

@traversc, would you be willing to set minimum versions of Rcpp and RcppParallel in the DESCRIPTION? It is difficult to know what to do with a compilation error when it happens.

wlandau avatar Jan 28 '25 19:01 wlandau

Looking again, I see you already set minimum versions, but maybe Rcpp >= 0.12.18.3 and RcppParallel >= 5.1.4 are too permissive?

wlandau avatar Jan 28 '25 19:01 wlandau

I believe RcppParallel version is fine, but Rcpp should 1.0.12.

Relevant commit: https://github.com/RcppCore/Rcpp/commit/b90ab6589eb10ac0ca63b7b9346dcab6d78e8b3a

But this isn't an issue specific to this package (there was a missing formatter string in Rcpp::warn) and every package using Rcpp should set this as a minimum. If that is the case, is it necessary to specify here?

traversc avatar Jan 28 '25 19:01 traversc

If that is the case, is it necessary to specify here?

Maybe not, if that's the issue. Tough to pin down on my end because I only see the error when I'm installing on R 4.4.0 in a big Docker container on GitHub Actions, and switching to the p3m binary avoids the issue entirely.

wlandau avatar Jan 30 '25 20:01 wlandau

I got "undefined symbol" again on library(stringfish). The source versions of Rcpp and RcppParallel do not seem to matter, but if the binaries are out of sync, then problems ensue.

This comes up regularly when I build Docker containers with renv libraries containing stringfish. A reprex is at https://github.com/wlandau/stringfish-reprex/tree/main I have an renv.lock file:

{
  "R": {
    "Version": "4.5.0",
    "Repositories": [
      {
        "Name": "CRAN",
        "URL": "https://packagemanager.posit.co/cran/latest"
      }
    ]
  },
  "Packages": {
    "Rcpp": {
      "Package": "Rcpp",
      "Version": "1.0.13-1",
      "Source": "Repository",
      "Repository": "RSPM",
      "Requirements": [
        "methods",
        "utils"
      ],
      "Hash": "6b868847b365672d6c1677b1608da9ed"
    },
    "RcppParallel": {
      "Package": "RcppParallel",
      "Version": "5.1.9",
      "Source": "Repository",
      "Repository": "RSPM",
      "Requirements": [
        "R"
      ],
      "Hash": "f38a72a419b91faac0ce5d9eee04c120"
    },
    "renv": {
      "Package": "renv",
      "Version": "1.0.11",
      "Source": "Repository",
      "Repository": "RSPM",
      "Requirements": [
        "utils"
      ],
      "Hash": "47623f66b4e80b3b0587bc5d7b309888"
    },
    "stringfish": {
      "Package": "stringfish",
      "Version": "0.16.0",
      "Source": "Repository",
      "Repository": "RSPM",
      "Requirements": [
        "R",
        "Rcpp",
        "RcppParallel"
      ],
      "Hash": "b7eb79470319ae71d4b5ed9cd7bf7294"
    }
  }
}

and a simple .github/workflows/reprex.yaml file which just restores the library:

on: [push]

name: reprex

jobs:
  reprex:
    runs-on: ubuntu-24.04
    steps:
      - uses: actions/checkout@v3
      - uses: r-lib/actions/setup-r@v2
        with:
          use-public-rspm: true
      - name: Install renv.
        run: install.packages("renv")
        shell: Rscript {0}
      - name: Restore packages.
        run: renv::restore()
        shell: Rscript {0}

the worker log shows an error loading the dynamic library:

# Downloading packages -------------------------------------------------------
- Querying repositories for available source packages ... Done!
- Downloading renv from RSPM ...                OK [2.1 Mb in 0.29s]
- Downloading Rcpp from RSPM ...                OK [2.1 Mb in 0.36s]
- Downloading RcppParallel from RSPM ...        OK [1.8 Mb in 0.45s]
- Downloading stringfish from RSPM ...          OK [414 Kb in 0.23s]
Successfully downloaded 4 packages in 2.8 seconds.

# Installing packages --------------------------------------------------------
- Installing renv ...                           OK [installed binary and cached in 0.32s]
- Installing Rcpp ...                           OK [installed binary and cached in 0.39s]
- Installing RcppParallel ...                   OK [installed binary and cached in 0.28s]
/opt/R/4.5.0/lib/R/bin/R --vanilla -s -f '/tmp/RtmpOdQyHl/renv-install-150a55e684eb.R'
================================================================================

Error in dyn.load(file, DLLpath = DLLpath, ...) : 
  unable to load shared object '/home/runner/work/_temp/Library/.renv/1/stringfish/libs/stringfish.so':
  /home/runner/work/_temp/Library/.renv/1/stringfish/libs/stringfish.so: undefined symbol: _ZN12RcppParallel14tbbParallelForEmmRNS_6WorkerEmi
Calls: loadNamespace -> library.dynam -> dyn.load
Execution halted

The versions of these packages are all compatible when built from the source:

      - uses: r-lib/actions/setup-r@v2
        with:
          use-public-rspm: false
      - name: Install packages.
        run: |
          install.packages("remotes")
          library(remotes)
          install_version("Rcpp", version = "1.0.13-1")
          install_version("RcppParallel", version = "5.1.9")
          install_version("stringfish", version = "0.16.0")
        shell: Rscript {0}

but the original dynamic library error surfaces when we use binaries of the same versions and the snapshot dates are different:

          install.packages(
            "stringfish",
            repos = "https://packagemanager.posit.co/cran/__linux__/noble/2024-12-01"
          )
          install.packages(
            "stringfish",
            repos = "https://packagemanager.posit.co/cran/__linux__/noble/2024-12-01"
          )
          install.packages(
            "stringfish",
            repos = "https://packagemanager.posit.co/cran/__linux__/noble/2025-06-02"
          )

Is there something that stringfish can do to be more resilient to old binaries of Rcpp and RcppParallel?

wlandau avatar Jun 03 '25 14:06 wlandau

@wlandau thanks for the reprex, I'll comment on the renv issue for better visibility

traversc avatar Jun 03 '25 16:06 traversc

Thanks for commenting on https://github.com/rstudio/renv/issues/2141. Seems to be a temporary issue due to changes in RcppParallel.

wlandau avatar Jun 06 '25 18:06 wlandau