Skip to content
The Chat Archive
o1-mini-2024-09-12· OpenAI WildChat-4.8M (AI2)

I am building an Rcpp package but i get devtools::check() ══ Documenting…

  1. User

    I am building an Rcpp package but i get

    devtools::check() ══ Documenting ══════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════ ℹ Installed roxygen2 version (7.3.1) doesn't match required (7.1.1) ✖ check() will not re-document this package ══ Building ═════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════ Setting env vars: • CFLAGS : -Wall -pedantic -fdiagnostics-color=always • CXXFLAGS : -Wall -pedantic -fdiagnostics-color=always • CXX11FLAGS: -Wall -pedantic -fdiagnostics-color=always • CXX14FLAGS: -Wall -pedantic -fdiagnostics-color=always • CXX17FLAGS: -Wall -pedantic -fdiagnostics-color=always • CXX20FLAGS: -Wall -pedantic -fdiagnostics-color=always ── R CMD build ────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────── ✔ checking for file ‘/home/jakob/R/x86_64-pc-linux-gnu-library/4.4/BISAM/DESCRIPTION’ ... ─ preparing ‘BISAM’: ✔ checking DESCRIPTION meta-information ... ─ excluding invalid files Subdirectory 'R' contains invalid file names: ‘BISAM’ ‘BISAM.rdb’ ‘BISAM.rdx’ ─ checking for LF line-endings in source and make files and shell scripts ─ checking for empty or unneeded directories Removed empty directory ‘BISAM/R’ WARNING: Removing directory ‘BISAM/Meta’ which should only occur in an installed package WARNING: Removing directory ‘BISAM/help’ which should only occur in an installed package WARNING: Removing directory ‘BISAM/html’ which should only occur in an installed package ─ building ‘BISAM_0.0.1.tar.gz’

    ══ Checking ═════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════ Setting env vars: • R_CHECK_CRAN_INCOMING_REMOTE : FALSE • R_CHECK_CRAN_INCOMING : FALSE • R_CHECK_FORCE_SUGGESTS : FALSE • R_CHECK_PACKAGES_USED_IGNORE_UNUSED_IMPORTS: FALSE • NOT_CRAN : true ── R CMD check ────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────── ─ using log directory ‘/tmp/RtmphfZQQ3/file4b78a6751b1d3/BISAM.Rcheck’ ─ using R version 4.4.1 (2024-06-14) ─ using platform: x86_64-pc-linux-gnu ─ R was compiled by gcc (GCC) 14.1.1 20240522 GNU Fortran (GCC) 14.1.1 20240522 ─ running under: Arch Linux ─ using session charset: UTF-8 ─ using options ‘--no-manual --as-cran’ (621ms) ✔ checking for file ‘BISAM/DESCRIPTION’ ─ checking extension type ... Package ─ this is package ‘BISAM’ version ‘0.0.1’ ─ package encoding: UTF-8 ✔ checking package namespace information ✔ checking package dependencies (1.6s) E checking if this is a source package ... Only source packages can be checked.

    See ‘/tmp/RtmphfZQQ3/file4b78a6751b1d3/BISAM.Rcheck/00check.log’ for details.

    ── R CMD check results ───────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────── BISAM 0.0.1 ──── Duration: 3.5s

    ❯ checking if this is a source package ... ERROR Only source packages can be checked.

  2. Assistant

    The error messages you're encountering during the devtools::check() process indicate a few underlying issues with your package setup. Let's address each problem step-by-step to help you successfully build and check your Rcpp package.

    1. Roxygen2 Version Mismatch

    Issue:

    ℹ Installed roxygen2 version (7.3.1) doesn't match required (7.1.1)
    ✖ `check()` will not re-document this package
    

    Solution: Your package specifies a dependency on roxygen2 version 7.1.1, but you have 7.3.1 installed. To resolve this:

    • Option A: Update the Package's DESCRIPTION File

      If possible, update the DESCRIPTION file of your package to accept newer versions of roxygen2. Open the DESCRIPTION file and locate the Suggests or Imports section, then modify the roxygen2 entry:

      Suggests: 
          roxygen2 (>= 7.1.1)
      

      This change allows roxygen2 versions 7.1.1 and above, ensuring compatibility with your installed version.

    • Option B: Install the Required Roxygen2 Version

      If your package strictly requires roxygen2 7.1.1, you can install this specific version from CRAN's archive:

      # Remove the current roxygen2 version
      remove.packages("roxygen2")
      
      # Install roxygen2 version 7.1.1
      install.packages("https://cran.r-project.org/src/contrib/Archive/roxygen2/roxygen2_7.1.1.tar.gz", repos = NULL, type = "source")
      

      Note: Using older versions might miss out on important updates and bug fixes. It's generally recommended to update the DESCRIPTION file unless there's a compelling reason to stick to an older version.

    2. Invalid Files and Directories in the Source Package

    Issue:

    Subdirectory 'R' contains invalid file names:
      ‘BISAM’ ‘BISAM.rdb’ ‘BISAM.rdx’
    
    WARNING: Removing directory ‘BISAM/Meta’ which should only occur in an installed package
    WARNING: Removing directory ‘BISAM/help’ which should only occur in an installed package
    WARNING: Removing directory ‘BISAM/html’ which should only occur in an installed package
    

    Explanation: The presence of .rdb, .rdx files and directories like Meta, help, and html within your package's source directory indicates that you're including files that are meant only for the installed version of the package. These files should not be part of the source package.

    Solution:

    1. Clean the Source Directory:

      • Remove Built Files: Navigate to the R/ directory of your package and ensure that only .R source files are present. Delete any .rdb, .rdx, or other non-source files.

      • Delete Unnecessary Directories: Remove directories like Meta, help, and html from the root of your package directory. These are generated during the build and install processes and should not be part of the source.

    2. Use .gitignore or Similar:

      If you're using version control (e.g., Git), update your .gitignore file to exclude these built files and directories to prevent them from being accidentally included in the source package.

      # R built files
      *.rdb
      *.rdx
      
      # Generated directories
      Meta/
      help/
      html/
      
    3. Clean Using Devtools:

      Utilize devtools functions to clean up built artifacts:

      devtools::clean_dll()
      

      This command removes compiled shared objects and can help ensure that no residual build artifacts are present.

    3. Finalizing the Check

    After addressing the above issues, proceed with the following steps:

    1. Regenerate Documentation:

      Since there was a roxygen2 version mismatch, regenerate your documentation to ensure it's up-to-date.

      devtools::document()
      
    2. Rebuild the Package:

      Build your package to create a fresh source tarball.

      devtools::build()
      
    3. Run the Check Again:

      Execute the check to verify that all issues have been resolved.

      devtools::check()
      

    4. Additional Recommendations

    • Ensure Clean Source Control:

      Make sure your source control (e.g., Git) repository contains only the necessary source files. Regularly check for accidentally committed build artifacts.

    • Continuous Integration (CI):

      Implement CI tools (like GitHub Actions) to automate checks. This helps in maintaining package integrity across different environments.

    • Review DESCRIPTION and NAMESPACE:

      Ensure that all dependencies are correctly listed and that the NAMESPACE file accurately reflects the exported functions and imported packages.

    5. Summary

    The main issues stem from:

    1. Roxygen2 Version Mismatch: Align your package's DESCRIPTION with your installed roxygen2 version or adjust the installed version to match your package requirements.
    2. Inclusion of Built Files: Clean your source package directory to exclude built artifacts and directories meant only for installed packages.

    By meticulously cleaning your package directory and ensuring that dependencies are correctly specified, you should be able to successfully build and check your Rcpp package without encountering the aforementioned errors.


    If issues persist, consider providing more details or the contents of the 00check.log file mentioned in the error message. This log can offer more insights into specific problems during the check process.