How to debug your package in a {rhub} fedora container before sending to CRAN?

It is not the first time I present how to debug on an other platform before sending your package to CRAN. This time, before submission {checkhelper} failed on ‘fedora’ image provided by {rhub}. How to debug your package using this platform when your using an other OS? Let’s speak about docker and VSCode…

Why another debug blog post?

In a previous blog post, I presented “Debug your package that failed on CRAN with {rhub}”. Here, this is exactly the same blog post, because, you know, I do not read my own blog posts, and I face and fix the same errors over and over…
But, I am not as stupid as I seem to be. Indeed, I could not reproduce the same steps because today, the rhub::local_check_linux() failed to work as expected. Maybe my local installation of docker is now different or something changed in the images… I don’t know.

Hence, if you want to explore locally what happens inside a {rhub} container, I suggest you try the first blog post, and if you can not, then follow this one.

Note that in the present blog post, I show tips to save the current docker image, and I also used VSCode to get inside the container.

In the debug series, there is also “How to debug your package on Win-Builder before sending to CRAN?”, which is different because you use the remote winbuilder to help you in the process, and there is no possibility for an interactive session.

Check your on {rhub} to explore results on multiple platforms

Before sending your package to CRAN, you probably check on {rhub} before.
With complicated packages, I like to test on multiple platforms to reduce risks of being rejected by CRAN after the first steps of submission. Indeed specific platforms like ‘fedora’ are being tested only after acceptance of your package on CRAN. If your package fails on these platforms after acceptance, you will only have 2 weeks to fix it.

To test on multiple images without having to build your package each time, I use to build it once and use argument path in the rhub::check...() functions as below:

buildpath <- devtools::build()
rhub::check_on_windows(check_args = "--force-multiarch", show_status = FALSE, path = buildpath)
rhub::check_on_solaris(show_status = FALSE, path = buildpath)
rhub::check(platform = "debian-clang-devel", show_status = FALSE, path = buildpath)
rhub::check(platform = "debian-gcc-devel", show_status = FALSE, path = buildpath)
rhub::check(platform = "fedora-clang-devel", show_status = FALSE, path = buildpath)
rhub::check_for_cran(show_status = FALSE, path = buildpath)

Check locally on these same platforms

With the function local_check_linux(), {rhub} allows you to run a docker container locally on your machine to realise the same tests as when sent to ‘rhub’ servers.
Using docker works well on Ubuntu distributions like I currently use.

rhub::local_check_linux(image = "rhub/fedora-clang-devel")

Explore and test from the inside of the container

The local_check_linux() function does not directly allow to run from the inside. Indeed, you’ll have to use the image from ‘rhub’ and run it with the interactive mode, find R, and install your dependencies.

To do so, open a Terminal on your machine and run the following command lines. Here I use “/home/seb/checkhelper” as the package I want to check inside the container. I need to mount this directory inside the container using argument -v.

# download rhub container
docker pull rhub/debian-clang-devel

# run container and mount your project inside
docker run -v /home/seb/checkhelper:/home/root/checkhelper -it rhub/fedora-clang-devel:latest bash

# Once inside, find and run R from "/opt"

You are now using R in the container. Install all dependencies, including “Suggests” if you want to be able to test your package.

remotes::install_deps(dependencies = TRUE)

# Install also devtools

Some packages may require extra system dependencies. Read carefully the installation errors to find the libraries to install.
For instance, I needed ‘openssl’.

You can stop the current R session (q()), install the dependency (yum install openssl-devel), reopen the R session (/opt/R-devel/bin/R) and re-run the R commands above.

After the installation, you can run the checks and try fo find the source of errors encountered!

Save the current state of the container for later use

If you stop your session, everything will be lost. You will have to start over from the beginning and re-install everything.

To avoid a full restart, you can save the current state of the container as a proper local docker image.

Open a new Terminal. Find the name of the container running (here ecstatic_rosalind).

docker ps -a
CONTAINER ID   IMAGE                            COMMAND                   CREATED        STATUS                    PORTS     NAMES
f17796ecc57e   rhub/fedora-clang-devel:latest   "bash"                    4 hours ago    Exited (0) 2 hours ago              ecstatic_rosalind

Commit the image with a new image name (here fedora-checkhelper). Change ecstatic_rosalind by the name of your container.

## commit the current running image to use for later
# docker commit ecstatic_rosalind fedora-checkhelper:latest

Next time, you will be able to start over with every R packages that you already installed, and continue your exploration with:

# run container and mount your project inside
docker run -v /home/seb/checkhelper:/home/root/checkhelper -it fedora-checkhelper:latest bash

# Once inside, find and run R from "/opt"

Use VSCode “Remote explorer” plugin to ease exploration

In my exploration, I chose to work with VSCode as it simplifies the interactive connection inside a running container. This allows to benefit all plugins of VSCode inside your container, interactively open your R files and launch your command with a classic CTRL+ENTER.

To do so, you need to have installed “Remote Explorer” and “Dev Containers” plugins, as well as the “Docker” plugin.

Open a Terminal to start the container.

docker run -v /home/seb/checkhelper:/home/root/checkhelper -it rhub/fedora-clang-devel:latest bash

Go to the Remote explorer menu and find the running container under “Dev Containers” sub-list.
Click the “Attach to New Window”. Do not close the Terminal you used to start running the container.
In the new window, you are inside the running Docker container. You can open the directory where your project is mounted. In my case: “/home/root/checkhelper”.
From here, you can open a Terminal (Menu Terminal > New Terminal).
Run /opt/R-devel/bin/R to start the R session.

Now you can use VSCode as your usual IDE!

If you are lost with VSCode, you can read my previous blog post on How not to be lost with VSCode when coming from RStudio?

See you soon for more adventures!


For attribution, please cite this work as:
Rochette Sébastien. (2023, Jun. 20). "How to debug your package in a {rhub} fedora container before sending to CRAN?". Retrieved from

BibTex citation:
    author = {Rochette Sébastien},
    title = {How to debug your package in a {rhub} fedora container before sending to CRAN?},
    url = {},
    year = {2023}