devtools package not installing on Rstudio for Linux

I am trying to install devtools in RStudio for Linux. My system details are:
-R 4.2.1
-RStudio 2022.07.01
-Linux mint 20.2

Here is the code I used within RStudio:

install.packages("devtools", dependencies = TRUE)

trying URL 'https://cloud.r-project.org/src/contrib/systemfonts_1.0.4.tar.gz'
Content type 'application/x-gzip' length 81757 bytes (79 KB)
==================================================
downloaded 79 KB

trying URL 'https://cloud.r-project.org/src/contrib/textshaping_0.3.6.tar.gz'
Content type 'application/x-gzip' length 35722 bytes (34 KB)
==================================================
downloaded 34 KB

trying URL 'https://cloud.r-project.org/src/contrib/ragg_1.2.2.tar.gz'
Content type 'application/x-gzip' length 424677 bytes (414 KB)
==================================================
downloaded 414 KB

trying URL 'https://cloud.r-project.org/src/contrib/pkgdown_2.0.6.tar.gz'
Content type 'application/x-gzip' length 871371 bytes (850 KB)
==================================================
downloaded 850 KB

trying URL 'https://cloud.r-project.org/src/contrib/devtools_2.4.4.tar.gz'
Content type 'application/x-gzip' length 374492 bytes (365 KB)
==================================================
downloaded 365 KB

begin installing package ‘systemfonts’
make: *** [Makefile:4: systemfonts.ts] Error 1
make: Target 'all' not remade because of errors.
* installing *source* package ‘systemfonts’ ...
** package ‘systemfonts’ successfully unpacked and MD5 sums checked
** using staged installation
Package fontconfig was not found in the pkg-config search path.
Perhaps you should add the directory containing `fontconfig.pc'
to the PKG_CONFIG_PATH environment variable
No package 'fontconfig' found
Package freetype2 was not found in the pkg-config search path.
Perhaps you should add the directory containing `freetype2.pc'
to the PKG_CONFIG_PATH environment variable
No package 'freetype2' found
Using PKG_CFLAGS=
Using PKG_LIBS=-lfontconfig -lfreetype
** libs
make[1]: Entering directory '/tmp/RtmpVv0dHi/R.INSTALL1c6c443d5d0cc/systemfonts/src'
rm -f systemfonts.so caches.o cpp11.o dev_metrics.o font_matching.o font_registry.o ft_cache.o string_shape.o font_metrics.o font_fallback.o string_metrics.o emoji.o cache_store.o init.o unix/FontManagerLinux.o
g++ -std=gnu++11 -I"/usr/share/R/include" -DNDEBUG  -I'/home/brant/R/x86_64-pc-linux-gnu-library/4.2/cpp11/include'    -fpic  -g -O2 -fdebug-prefix-map=/build/r-base-asoVQd/r-base-4.2.1=. -fstack-protector-strong -Wformat -Werror=format-security -Wdate-time -D_FORTIFY_SOURCE=2  -c caches.cpp -o caches.o
In file included from caches.h:7:0,
                 from caches.cpp:1:
ft_cache.h:9:22: fatal error: ft2build.h: No such file or directory
compilation terminated.
make[1]: *** [/usr/lib/R/etc/Makeconf:177: caches.o] Error 1
make[1]: Leaving directory '/tmp/RtmpVv0dHi/R.INSTALL1c6c443d5d0cc/systemfonts/src'
ERROR: compilation failed for package ‘systemfonts’
* removing ‘/home/brant/R/x86_64-pc-linux-gnu-library/4.2/systemfonts’
cat: textshaping.out: No such file or directory
cat: ragg.out: No such file or directory
cat: pkgdown.out: No such file or directory
cat: devtools.out: No such file or directory

The downloaded source packages are in
	‘/tmp/RtmpYn6Owq/downloaded_packages’

I am not really that proficient in Linux yet so I don't understand why this package is not installing. Any help welcome.

Canuck_afar

I was able to add the freetype2.pc and fontconfig.pc files to the PKG_CONFIG_PATH which reduced the error message. Now I think the issue is with the systemfonts package. Here is what I get

> install.packages('systemfonts')

Installing package into ‘/home/brant/R/x86_64-pc-linux-gnu-library/4.2’
(as ‘lib’ is unspecified)
trying URL 'https://cloud.r-project.org/src/contrib/systemfonts_1.0.4.tar.gz'
Content type 'application/x-gzip' length 81757 bytes (79 KB)
==================================================
downloaded 79 KB

* installing *source* package ‘systemfonts’ ...
** package ‘systemfonts’ successfully unpacked and MD5 sums checked
** using staged installation
Found pkg-config cflags and libs!
Using PKG_CFLAGS=
Using PKG_LIBS=-L/home/brant/anaconda3/envs/rstudio/lib -lfontconfig -lfreetype
** libs
rm -f systemfonts.so caches.o cpp11.o dev_metrics.o font_matching.o font_registry.o ft_cache.o string_shape.o font_metrics.o font_fallback.o string_metrics.o emoji.o cache_store.o init.o unix/FontManagerLinux.o
g++ -std=gnu++11 -I"/usr/share/R/include" -DNDEBUG  -I'/home/brant/R/x86_64-pc-linux-gnu-library/4.2/cpp11/include'    -fpic  -g -O2 -fdebug-prefix-map=/build/r-base-asoVQd/r-base-4.2.1=. -fstack-protector-strong -Wformat -Werror=format-security -Wdate-time -D_FORTIFY_SOURCE=2  -c caches.cpp -o caches.o
In file included from caches.h:7:0,
                 from caches.cpp:1:
ft_cache.h:9:22: fatal error: ft2build.h: No such file or directory
compilation terminated.
make: *** [/usr/lib/R/etc/Makeconf:177: caches.o] Error 1
ERROR: compilation failed for package ‘systemfonts’
* removing ‘/home/brant/R/x86_64-pc-linux-gnu-library/4.2/systemfonts’
Warning in install.packages :
  installation of package ‘systemfonts’ had non-zero exit status

The downloaded source packages are in
	‘/tmp/RtmpvtPTnY/downloaded_packages’

Any ideas? Thank you in advance.

Stand-alone R doesn't work nicely with anaconda environments, you should stick with one or the other, if you want to set your environment using conda you should also use the R core provided with the anaconda distribution and install packages using conda not CRAN (install.packages()).
If you want to use the stand-alone R installation, do not refer to conda environments.

To address your original issue, have you tried simply installing the missing system dependency?

sudo apt install libfontconfig1-dev

This topic was automatically closed 21 days after the last reply. New replies are no longer allowed.

If you have a query related to it or one of the replies, start a new topic and refer back with a link.