install R version 4 fails on RHEL7

Dear,

I am desperately trying to get R version 4.x on my Redhat server which only gets 3.6 through yum (EPEL does not go higher).

I tried both install from RPM and from source as detailed in the otherwise very nice Posit page Posit - Install R - Posit Documentation

In both cases, I end up with an incomplete install lacking several folders (under which library) and consequently a R command returning the following errors at start

/opt/R/4.1.3 $  ll
total 0
drwxr-xr-x. 5 root root 38 Jan  5 16:24 .
drwxr-xr-x. 3 root root 18 Jan  5 16:24 ..
drwxr-xr-x. 2 root root 28 Jan  5 16:24 bin
drwxr-xr-x. 4 root root 30 Jan  5 16:24 lib
drwxr-xr-x. 3 root root 16 Jan  5 16:24 share

Does anyone here have a way to correct this and get a full R install on RHEL? (using version 3.6 is not an option for me; neither moving to ubuntu on that server)

**/opt/R/4.1.3** $ bin/R

Error in gzfile(file, "rb") : cannot open the connection
In addition: Warning message:
In gzfile(file, "rb") :
cannot open compressed file '/usr/lib64/R/library/base/R/base.rdx', probable reason 'No such file or directory'
Error: could not find function "attach"

R version 4.1.3 (2022-03-10) -- "One Push-Up"
Copyright (C) 2022 The R Foundation for Statistical Computing
Platform: x86_64-pc-linux-gnu (64-bit)
R is free software and comes with ABSOLUTELY NO WARRANTY.
You are welcome to redistribute it under certain conditions.
Type 'license()' or 'licence()' for distribution details.
Natural language support but running in an English locale
R is a collaborative project with many contributors.
Type 'contributors()' for more information and
'citation()' on how to cite R or R packages in publications.
Type 'demo()' for some demos, 'help()' for on-line help, or
'help.start()' for an HTML browser interface to help.
Type 'q()' to quit R.

Error: object '.ArgsEnv' not found
Fatal error: unable to initialize the JIT

I might have spotted something after retrying from source.

somehow, the make process is hardcoding /usr/local/lib64 as a destination, thereby ignoring the prefix /opt/R/${R_VERSION} provided during configure

./configure \
>     --prefix=/opt/R/${R_VERSION} \
>     --enable-memory-profiling \
>     --enable-R-shlib \
>     --with-blas \
>     --with-lapack

The result is that the installed R exec is looking in /usr/local/lib64 for libraries which are in fact located in /opt/R/${R_VERSION}...

I am not famliliar withj Makefiles but I suspect that there is something basically wrong there with some make steps.

I could 'fix' the issue by manually creating a symlink in /usr/lib64 pointing to the physical path /opt/R/${R_VERSION}/lib64/R/

BTW in that location, I find all the expected folders for a normal install including the library folder, they are just deeply nested inside the install folder, in my case the actuall files are in /opt/R/${R_VERSION}/lib64/R/ which is not the usual behaviour like under ubuntu

ll /opt/R/4.1.3/lib64/R/
total 48K
drwxr-xr-x. 10 root root 4.0K Jan  5 18:01 .
drwxr-xr-x.  4 root root   30 Jan  5 18:01 ..
drwxr-xr-x.  3 root root 4.0K Jan  5 18:01 bin
-rw-r--r--.  1 root root  18K Jan  5 18:01 COPYING
drwxr-xr-x.  4 root root 4.0K Jan  5 18:01 doc
drwxr-xr-x.  2 root root   84 Jan  5 18:01 etc
drwxr-xr-x.  3 root root 4.0K Jan  5 18:01 include
drwxr-xr-x.  2 root root   20 Jan  5 18:01 lib
drwxr-xr-x. 32 root root 4.0K Jan  5 18:01 library
drwxr-xr-x.  2 root root   69 Jan  5 18:01 modules
drwxr-xr-x. 11 root root 4.0K Jan  5 18:01 share
-rw-r--r--.  1 root root   46 Jan  5 18:01 SVN-REVISION

Hope this will give good ideas to someone more qualified than me to fix the RHEL makefile of R version 4.1.3!!