ggsave using svg device throwing "bad value" error following update of package

111 views Asked by At

I am adding another example of: Don't update packages when working with a perfectly fine running script!

I am struggling to find the solution for an error which is thrown by ggplot's ggsave function after updating several packages yesterday.

Prior to the update, everything worked fine, but afterwards the same script (no changes made) threw the following error:

> ggplot2::ggsave(
+   filename = params$file_plot_output,
+   plot = p1
+ )
Error in match_font_c(family, as.logical(italic), as.logical(bold)) : 
  bad value

> sessionInfo()
R version 4.3.1 (2023-06-16)
Platform: aarch64-apple-darwin20 (64-bit)
Running under: macOS Sonoma 14.0

Matrix products: default
BLAS:   /System/Library/Frameworks/Accelerate.framework/Versions/A/Frameworks/vecLib.framework/Versions/A/libBLAS.dylib 
LAPACK: /Library/Frameworks/R.framework/Versions/4.3-arm64/Resources/lib/libRlapack.dylib;  LAPACK version 3.11.0

locale:
[1] en_US.UTF-8/en_US.UTF-8/en_US.UTF-8/C/en_US.UTF-8/en_US.UTF-8

time zone: America/New_York
tzcode source: internal

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

other attached packages:
[1] stringr_1.5.0 RSQLite_2.3.1 readxl_1.4.3  dplyr_1.1.3  

loaded via a namespace (and not attached):
 [1] bit_4.0.5         gtable_0.3.4      compiler_4.3.1    crayon_1.5.2     
 [5] tidyselect_1.2.0  blob_1.2.4        tidyr_1.3.0       textshaping_0.3.7
 [9] systemfonts_1.0.5 scales_1.2.1      yaml_2.3.7        fastmap_1.1.1    
[13] ggplot2_3.4.4     R6_2.5.1          generics_0.1.3    tibble_3.2.1     
[17] munsell_0.5.0     svglite_2.1.2     DBI_1.1.3         pillar_1.9.0     
[21] rlang_1.1.1       utf8_1.2.3        cachem_1.0.8      stringi_1.7.12   
[25] bit64_4.0.5       memoise_2.0.1     cli_3.6.1         withr_2.5.1      
[29] magrittr_2.0.3    grid_4.3.1        rstudioapi_0.15.0 lifecycle_1.0.3  
[33] vctrs_0.6.4       glue_1.6.2        cellranger_1.1.0  ragg_1.2.6       
[37] fansi_1.0.5       colorspace_2.1-0  purrr_1.0.2       tools_4.3.1      
[41] pkgconfig_2.0.3  

I did some troubleshooting with installing/reinstalling brew/fontconfig/cairo. Also installed/reinstalled the extrafont package and the svglite package, but nothing fixed the problem.

I know this is currently not a lot of information to troubleshoot, but maybe someone can point me in the right direction. I cannot really identify where the problem lies given the error message. I also tried to change the font (family argument for theme in ggplot2), but this did not help either.

The problem seems to be specific for svg. I have no problems saving the exact image/plot as PDF, png and so on.

Alternatively, if someone has a quick way of reinstating my last package setup (basically rolling back the updates I made yesterday), that would be great too.

Any help is highly appreciated! Thanks!

0

There are 0 answers