I can't seem to install devtools under WSL2 / Ubuntu 20.04 / Windows 10.
The apparent error message is about xml2 but quite a bit of googling suggests that at least part of the problem is the location of the libxml2 installation or the libxml2-dev installation, both of which appear to be standard to me.
> install.packages("devtools")
Installing package into ‘/home/mcq/R/x86_64-pc-linux-gnu-library/4.1’
(as ‘lib’ is unspecified)
also installing the dependencies ‘xml2’, ‘roxygen2’, ‘rversions’
trying URL 'https://cran.microsoft.com/src/contrib/xml2_1.3.3.tar.gz'
Content type 'application/octet-stream' length 283965 bytes (277 KB)
==================================================
downloaded 277 KB
trying URL 'https://cran.microsoft.com/src/contrib/roxygen2_7.1.2.tar.gz'
Content type 'application/octet-stream' length 267337 bytes (261 KB)
==================================================
downloaded 261 KB
trying URL 'https://cran.microsoft.com/src/contrib/rversions_2.1.1.tar.gz'
Content type 'application/octet-stream' length 42064 bytes (41 KB)
==================================================
downloaded 41 KB
trying URL 'https://cran.microsoft.com/src/contrib/devtools_2.4.3.tar.gz'
Content type 'application/octet-stream' length 372413 bytes (363 KB)
==================================================
downloaded 363 KB
* installing *source* package ‘xml2’ ...
** package ‘xml2’ successfully unpacked and MD5 sums checked
** using staged installation
Found pkg-config cflags and libs!
Using PKG_CFLAGS=-I/usr/include/libxml2
Using PKG_LIBS=-lxml2
** libs
g++ -std=gnu++14 -I"/usr/share/R/include" -DNDEBUG -I../inst/include -I/usr/include/libxml2 -DUCHAR_TYPE=wchar_t -DU_SHOW_CPLUSPLUS_API=0 -fvisibility=hidden -fpic -g -O2 -fdebug-prefix-map=/build/r-base-lENDSu/r-base-4.1.3=. -fstack-protector-strong -Wformat -Werror=format-security -Wdate-time -D_FORTIFY_SOURCE=2 -g -c connection.cpp -o connection.o
gcc -I"/usr/share/R/include" -DNDEBUG -I../inst/include -I/usr/include/libxml2 -DUCHAR_TYPE=wchar_t -DU_SHOW_CPLUSPLUS_API=0 -fpic -g -O2 -fdebug-prefix-map=/build/r-base-lENDSu/r-base-4.1.3=. -fstack-protector-strong -Wformat -Werror=format-security -Wdate-time -D_FORTIFY_SOURCE=2 -g -c init.c -o init.o
g++ -std=gnu++14 -I"/usr/share/R/include" -DNDEBUG -I../inst/include -I/usr/include/libxml2 -DUCHAR_TYPE=wchar_t -DU_SHOW_CPLUSPLUS_API=0 -fvisibility=hidden -fpic -g -O2 -fdebug-prefix-map=/build/r-base-lENDSu/r-base-4.1.3=. -fstack-protector-strong -Wformat -Werror=format-security -Wdate-time -D_FORTIFY_SOURCE=2 -g -c xml2_doc.cpp -o xml2_doc.o
g++ -std=gnu++14 -I"/usr/share/R/include" -DNDEBUG -I../inst/include -I/usr/include/libxml2 -DUCHAR_TYPE=wchar_t -DU_SHOW_CPLUSPLUS_API=0 -fvisibility=hidden -fpic -g -O2 -fdebug-prefix-map=/build/r-base-lENDSu/r-base-4.1.3=. -fstack-protector-strong -Wformat -Werror=format-security -Wdate-time -D_FORTIFY_SOURCE=2 -g -c xml2_init.cpp -o xml2_init.o
g++ -std=gnu++14 -I"/usr/share/R/include" -DNDEBUG -I../inst/include -I/usr/include/libxml2 -DUCHAR_TYPE=wchar_t -DU_SHOW_CPLUSPLUS_API=0 -fvisibility=hidden -fpic -g -O2 -fdebug-prefix-map=/build/r-base-lENDSu/r-base-4.1.3=. -fstack-protector-strong -Wformat -Werror=format-security -Wdate-time -D_FORTIFY_SOURCE=2 -g -c xml2_namespace.cpp -o xml2_namespace.o
g++ -std=gnu++14 -I"/usr/share/R/include" -DNDEBUG -I../inst/include -I/usr/include/libxml2 -DUCHAR_TYPE=wchar_t -DU_SHOW_CPLUSPLUS_API=0 -fvisibility=hidden -fpic -g -O2 -fdebug-prefix-map=/build/r-base-lENDSu/r-base-4.1.3=. -fstack-protector-strong -Wformat -Werror=format-security -Wdate-time -D_FORTIFY_SOURCE=2 -g -c xml2_node.cpp -o xml2_node.o
g++ -std=gnu++14 -I"/usr/share/R/include" -DNDEBUG -I../inst/include -I/usr/include/libxml2 -DUCHAR_TYPE=wchar_t -DU_SHOW_CPLUSPLUS_API=0 -fvisibility=hidden -fpic -g -O2 -fdebug-prefix-map=/build/r-base-lENDSu/r-base-4.1.3=. -fstack-protector-strong -Wformat -Werror=format-security -Wdate-time -D_FORTIFY_SOURCE=2 -g -c xml2_output.cpp -o xml2_output.o
g++ -std=gnu++14 -I"/usr/share/R/include" -DNDEBUG -I../inst/include -I/usr/include/libxml2 -DUCHAR_TYPE=wchar_t -DU_SHOW_CPLUSPLUS_API=0 -fvisibility=hidden -fpic -g -O2 -fdebug-prefix-map=/build/r-base-lENDSu/r-base-4.1.3=. -fstack-protector-strong -Wformat -Werror=format-security -Wdate-time -D_FORTIFY_SOURCE=2 -g -c xml2_schema.cpp -o xml2_schema.o
g++ -std=gnu++14 -I"/usr/share/R/include" -DNDEBUG -I../inst/include -I/usr/include/libxml2 -DUCHAR_TYPE=wchar_t -DU_SHOW_CPLUSPLUS_API=0 -fvisibility=hidden -fpic -g -O2 -fdebug-prefix-map=/build/r-base-lENDSu/r-base-4.1.3=. -fstack-protector-strong -Wformat -Werror=format-security -Wdate-time -D_FORTIFY_SOURCE=2 -g -c xml2_url.cpp -o xml2_url.o
g++ -std=gnu++14 -I"/usr/share/R/include" -DNDEBUG -I../inst/include -I/usr/include/libxml2 -DUCHAR_TYPE=wchar_t -DU_SHOW_CPLUSPLUS_API=0 -fvisibility=hidden -fpic -g -O2 -fdebug-prefix-map=/build/r-base-lENDSu/r-base-4.1.3=. -fstack-protector-strong -Wformat -Werror=format-security -Wdate-time -D_FORTIFY_SOURCE=2 -g -c xml2_xpath.cpp -o xml2_xpath.o
g++ -std=gnu++14 -shared -L/usr/lib/R/lib -Wl,-Bsymbolic-functions -Wl,-z,relro -o xml2.so connection.o init.o xml2_doc.o xml2_init.o xml2_namespace.o xml2_node.o xml2_output.o xml2_schema.o xml2_url.o xml2_xpath.o -lxml2 -L/usr/lib/R/lib -lR
installing to /home/mcq/R/x86_64-pc-linux-gnu-library/4.1/00LOCK-xml2/00new/xml2/libs
** R
** inst
** byte-compile and prepare package for lazy loading
** help
*** installing help indices
** building package indices
** installing vignettes
** testing if installed package can be loaded from temporary location
** checking absolute paths in shared objects and dynamic libraries
mv: cannot move '/home/mcq/R/x86_64-pc-linux-gnu-library/4.1/00LOCK-xml2/00new/xml2' to '/home/mcq/R/x86_64-pc-linux-gnu-library/4.1/xml2': Permission denied
ERROR: moving to final location failed
I'm not sure if I should post more contextual info about this but would be happy to do so.