Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Installation fails due to compilation error: "format not a string literal and no format arguments [-Werror=format-security]" #123

Closed
naikymen opened this issue May 31, 2024 · 11 comments

Comments

@naikymen
Copy link

Hi! I'm having trouble installing the package on Arch Linux.

Error message:

* installing *source* package ‘S4Vectors’ ...
** using staged installation
** libs
using C compiler: ‘gcc (GCC) 14.1.1 20240522’
gcc -I"/usr/include/R/" -DNDEBUG   -I/usr/local/include    -fpic  -march=x86-64 -mtune=generic -O2 -pipe -fno-plt -fexceptions         -Wp,-D_FORTIFY_SOURCE=3 -Wformat -Werror=format-security         -fstack-clash-protection -fcf-protection         -fno-omit-frame-pointer -mno-omit-leaf-frame-pointer -g -ffile-prefix-map=/build/r/src=/usr/src/debug/r -flto=auto -ffat-lto-objects  -c AEbufs.c -o AEbufs.o
gcc -I"/usr/include/R/" -DNDEBUG   -I/usr/local/include    -fpic  -march=x86-64 -mtune=generic -O2 -pipe -fno-plt -fexceptions         -Wp,-D_FORTIFY_SOURCE=3 -Wformat -Werror=format-security         -fstack-clash-protection -fcf-protection         -fno-omit-frame-pointer -mno-omit-leaf-frame-pointer -g -ffile-prefix-map=/build/r/src=/usr/src/debug/r -flto=auto -ffat-lto-objects  -c DataFrame_class.c -o DataFrame_class.o
gcc -I"/usr/include/R/" -DNDEBUG   -I/usr/local/include    -fpic  -march=x86-64 -mtune=generic -O2 -pipe -fno-plt -fexceptions         -Wp,-D_FORTIFY_SOURCE=3 -Wformat -Werror=format-security         -fstack-clash-protection -fcf-protection         -fno-omit-frame-pointer -mno-omit-leaf-frame-pointer -g -ffile-prefix-map=/build/r/src=/usr/src/debug/r -flto=auto -ffat-lto-objects  -c Hits_class.c -o Hits_class.o
gcc -I"/usr/include/R/" -DNDEBUG   -I/usr/local/include    -fpic  -march=x86-64 -mtune=generic -O2 -pipe -fno-plt -fexceptions         -Wp,-D_FORTIFY_SOURCE=3 -Wformat -Werror=format-security         -fstack-clash-protection -fcf-protection         -fno-omit-frame-pointer -mno-omit-leaf-frame-pointer -g -ffile-prefix-map=/build/r/src=/usr/src/debug/r -flto=auto -ffat-lto-objects  -c LLint_class.c -o LLint_class.o
gcc -I"/usr/include/R/" -DNDEBUG   -I/usr/local/include    -fpic  -march=x86-64 -mtune=generic -O2 -pipe -fno-plt -fexceptions         -Wp,-D_FORTIFY_SOURCE=3 -Wformat -Werror=format-security         -fstack-clash-protection -fcf-protection         -fno-omit-frame-pointer -mno-omit-leaf-frame-pointer -g -ffile-prefix-map=/build/r/src=/usr/src/debug/r -flto=auto -ffat-lto-objects  -c List_class.c -o List_class.o
gcc -I"/usr/include/R/" -DNDEBUG   -I/usr/local/include    -fpic  -march=x86-64 -mtune=generic -O2 -pipe -fno-plt -fexceptions         -Wp,-D_FORTIFY_SOURCE=3 -Wformat -Werror=format-security         -fstack-clash-protection -fcf-protection         -fno-omit-frame-pointer -mno-omit-leaf-frame-pointer -g -ffile-prefix-map=/build/r/src=/usr/src/debug/r -flto=auto -ffat-lto-objects  -c R_init_S4Vectors.c -o R_init_S4Vectors.o
gcc -I"/usr/include/R/" -DNDEBUG   -I/usr/local/include    -fpic  -march=x86-64 -mtune=generic -O2 -pipe -fno-plt -fexceptions         -Wp,-D_FORTIFY_SOURCE=3 -Wformat -Werror=format-security         -fstack-clash-protection -fcf-protection         -fno-omit-frame-pointer -mno-omit-leaf-frame-pointer -g -ffile-prefix-map=/build/r/src=/usr/src/debug/r -flto=auto -ffat-lto-objects  -c Rle_class.c -o Rle_class.o
Rle_class.c: In function ‘_subset_Rle_by_ranges’:
Rle_class.c:1136:17: error: format not a string literal and no format arguments [-Werror=format-security]
 1136 |                 error(errmsg);
      |                 ^~~~~
Rle_class.c: In function ‘_subset_Rle_by_positions’:
Rle_class.c:1161:17: error: format not a string literal and no format arguments [-Werror=format-security]
 1161 |                 error(errmsg);
      |                 ^~~~~
Rle_class.c: In function ‘Rle_extract_range’:
Rle_class.c:1190:17: error: format not a string literal and no format arguments [-Werror=format-security]
 1190 |                 error(errmsg);
      |                 ^~~~~
cc1: some warnings being treated as errors
make: *** [/usr/lib64/R/etc/Makeconf:195: Rle_class.o] Error 1
ERROR: compilation failed for package ‘S4Vectors’
* removing ‘/home/nicomic/R/x86_64-pc-linux-gnu-library/4.4/S4Vectors’

R version:

> R.version
               _                           
platform       x86_64-pc-linux-gnu         
arch           x86_64                      
os             linux-gnu                   
system         x86_64, linux-gnu           
status                                     
major          4                           
minor          4.0                         
year           2024                        
month          04                          
day            24                          
svn rev        86474                       
language       R                           
version.string R version 4.4.0 (2024-04-24)
nickname       Puppy Cup
@naikymen
Copy link
Author

The error does not appear when installing from source:

remotes::install_github("https://github.com/Bioconductor/S4Vectors.git")

@hpages
Copy link
Contributor

hpages commented May 31, 2024

You're installing from source in both case. However, in the first case, you're not showing what command you're using to install the package. You're also not showing your sessionInfo() so we don't know what version of Bioconductor you are using.

Make sure to always use BiocManager::install() when installing Bioconductor packages, and to always use the latest version of Bioconductor (BioC 3.19, released at the beginning of May). Installing directly from GitHub is strongly discouraged as it will get you a version of the package that does not match your version of Bioconductor, which will lead to all kinds of problems downstream.

@naikymen
Copy link
Author

naikymen commented Jun 3, 2024

You're also not showing your sessionInfo() so we don't know what version of Bioconductor you are using.

Thanks for the hint, here it is:

sessionInfo()
R version 4.4.0 (2024-04-24)
Platform: x86_64-pc-linux-gnu
Running under: Arch Linux

Matrix products: default
BLAS:   /usr/lib/libblas.so.3.12.0 
LAPACK: /usr/lib/liblapack.so.3.12.0

locale:
 [1] LC_CTYPE=en_US.UTF-8       LC_NUMERIC=C               LC_TIME=en_US.UTF-8        LC_COLLATE=en_US.UTF-8     LC_MONETARY=en_US.UTF-8   
 [6] LC_MESSAGES=en_US.UTF-8    LC_PAPER=en_US.UTF-8       LC_NAME=C                  LC_ADDRESS=C               LC_TELEPHONE=C            
[11] LC_MEASUREMENT=en_US.UTF-8 LC_IDENTIFICATION=C       

time zone: America/Buenos_Aires
tzcode source: system (glibc)

attached base packages:
[1] stats     graphics  grDevices utils     datasets  methods   base     

loaded via a namespace (and not attached):
 [1] miniUI_0.1.1.1    compiler_4.4.0    promises_1.3.0    Rcpp_1.0.12       stringr_1.5.1     callr_3.7.6       later_1.3.2       fastmap_1.2.0    
 [9] mime_0.12         R6_2.5.1          htmlwidgets_1.6.4 tibble_3.2.1      desc_1.4.3        profvis_0.3.8     shiny_1.8.1.1     pillar_1.9.0     
[17] rlang_1.1.3       utf8_1.2.4        cachem_1.1.0      stringi_1.8.4     httpuv_1.6.15     fs_1.6.4          pkgload_1.3.4     memoise_2.0.1    
[25] cli_3.6.2         magrittr_2.0.3    ps_1.7.6          processx_3.8.4    digest_0.6.35     rstudioapi_0.16.0 xtable_1.8-4      remotes_2.5.0    
[33] devtools_2.4.5    lifecycle_1.0.4   vctrs_0.6.5       glue_1.7.0        urlchecker_1.0.1  sessioninfo_1.2.2 pkgbuild_1.4.4    fansi_1.0.6      
[41] purrr_1.0.2       pkgconfig_2.0.3   tools_4.4.0       usethis_2.2.3     ellipsis_0.3.2    htmltools_0.5.8.1

Make sure to always use BiocManager::install() when installing Bioconductor packages

I'm installing a package I made with devtools::install. The package uses biocviews: in its DESCRIPTION file to resolve bioconductor dependencies.

However, in that case the dependency resolves to an older version of BioConductor (3.18):

trying URL 'https://bioconductor.org/packages/3.18/bioc/src/contrib/S4Vectors_0.40.2.tar.gz'

Manually running BiocManager::install() uses the later version (3.19), and does not fail:

trying URL 'https://bioconductor.org/packages/3.19/bioc/src/contrib/S4Vectors_0.42.0.tar.gz'

This last bit is reasonable, since BiocManager is on that version:

> BiocManager::version() # Verify version
[1] ‘3.19’

I don't know why there is a difference between devtools and BiocManager installs, nor how to specify the proper BioConductor version in my DESCRIPTION file.

@LiNk-NY
Copy link
Contributor

LiNk-NY commented Jun 3, 2024

I'm installing a package I made with devtools::install. The package uses biocviews: in its DESCRIPTION file to resolve bioconductor dependencies.

Hi @naikymen
This is not the proper way to install or resolve Bioconductor dependencies and you do so at your own risk. Please refer to the BiocManager vignette for setup instructions. With R 4.4.0, developers should be using Bioconductor version 3.20.
You can install Bioconductor devel (version 3.20) with:

BiocManager::install(version = "devel")

If you need to install Bioconductor dependencies for your package, use remotes::install_local:

remotes::install_local("./myPackage", repos = BiocManager::repositories(), dependencies = TRUE)

(Presumably you have a local checkout of the package that you are developing.)

PS. Bioconductor 3.18 uses R 4.3.0 so that is not compatible with your installation.

Best regards,
Marcel

@mtmorgan
Copy link

mtmorgan commented Jun 3, 2024

I've sometimes seen the advice to add biocViews: to the DESCRIPTION file, and have wondered where it came from. I see one place with a lot of references is in a devtools issue comment r-lib/devtools#700 (comment) from 2016, but

This trick is not documented anywhere

I'm guessing that this comes from the remotes package https://github.com/r-lib/remotes/blob/5b7eb08f70ecc4f885f2c75330ce77f87e7dd14e/R/bioc-standalone.R#L217. Looking at the code makes it seem like it will do something close to the right thing, looking first in a hard-coded map and then parsing bioconductor.org/config.yaml if necessary. @LiNk-NY is the logic in the remotes package incorrect? @naikymen what command were you using when trying to install with devtools? Can you make a simple reproducible example (e.g., if it is your own package, pointing to a public repository)?

@naikymen
Copy link
Author

naikymen commented Jun 3, 2024

Hello Marcel and mtmorgan, thank you for the responses.

Do you mean that biocviews: is not recommended? It is the only way I've found to automatically install BioC dependencies, as listed in my DESCRIPTION file. I apologize if I missed it, but there seems to be no information about this in the vignette (that I could understand).

I want to provide my users with a simple way to install my package. So far I had been using remotes::install_github (without the repos argument, and with biocviews:) and it had worked.

Now the problem seems to be that devtools and install_github choose an older BioConductor version for some reason.

The following is an acceptable solution for me (thanks!). However, I'd like to check if it is the proper way for users to install my package (or any R package at GitHub) with the latest versions of BioConductor dependencies:

install.packages("BiocManager")
remotes::install_github("darksideoftheshmoo/rcell2-magick", repos = BiocManager::repositories())

Should I still include biocViews: in my DESCRIPTION file in that case?

what command were you using when trying to install with devtools? Can you make a simple reproducible example (e.g., if it is your own package, pointing to a public repository)?

The commands that fail are:

devtools::install() # Install from the current directory.
remotes::install_github("darksideoftheshmoo/rcell2-magick") # Install from GitHub.

Here is the repository: https://github.com/darksideoftheshmoo/rcell2-magick

And here is a reprex with a dummy package: https://github.com/darksideoftheshmoo/reprex

remotes::install_github("darksideoftheshmoo/reprex") # Install from GitHub.

That command uses Bioc 3.18 and fails during compilation. Adding repos = BiocManager::repositories() fixes the issue.

@naikymen
Copy link
Author

naikymen commented Jun 3, 2024

PS. Bioconductor 3.18 uses R 4.3.0 so that is not compatible with your installation.

This is what strikes me. I'm on R 4.4.0, so why would remotes use an incompatible BioC version?

@naikymen
Copy link
Author

naikymen commented Jun 3, 2024

@naikymen
Copy link
Author

naikymen commented Jun 3, 2024

Closing this, as it is not related to S4Vectors at all. Raised an issue in remotes: r-lib/remotes#798

Thank you for your help!

@naikymen naikymen closed this as completed Jun 3, 2024
@LiNk-NY
Copy link
Contributor

LiNk-NY commented Jun 4, 2024

Thanks Martin, @mtmorgan

@LiNk-NY is the logic in the remotes package incorrect?

That seems to be the case. It returns 3.18 on R version 4.4.0:

> remotes:::bioconductor$get_matching_bioc_version()
[1] '3.18'
> getRversion()
[1] '4.4.0'
> 

Thanks Nicolás for opening an issue at @r-lib/remotes

@mtmorgan
Copy link

mtmorgan commented Jun 4, 2024

FWIW I would install CRAN or GitHub packages that directly or indirectly depend on Bioconductor packages with something like

pkgs <- setdiff(c("BiocManager", "remotes"), rownames(installed.packages()))
install.packages(pkgs, repos = "https://cloud.R-project.org")
BiocManager::install("darksideoftheshmoo/reprex")

The instructions in section 2.3 of the BiocManager vignette would lead to this solution (trying without first installing remotes would lead to a prompt describing how to install remotes).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants