R shared library (/usr/local/lib/R/lib/libR.so) not found. If this is a custom build of R, was it built with the --enable-R-shlib option?

Ubuntu 21.1
I updated RStudio to the most recent version and then updated R to 4.1.2 and RStudio is now giving me this error

R shared library (/usr/local/lib/R/lib/libR.so) not found. If this is a custom build of R, was it built with the --enable-R-shlib option?

There was a similar problem reported here but the solution does not work as I have no /home/jrkrideau/R-4.1.2/lib/ folder that I can see.
RStudio possible solution?

I currently seem to have libR.so in usr/lib and usr/local/lib/r/lib

Any suggestions on how to get out out of this.

Note I installed R-4.1.2 from a .tar.gz file which probably caused most of the problem.

A solution for this would be compiling R yourself with the needed flag.

sudo apt-get install -y gfortran libreadline6-dev libx11-dev libxt-dev \
                               libpng-dev libjpeg-dev libcairo2-dev xvfb \
                               libbz2-dev libzstd-dev liblzma-dev \
                               libcurl4-openssl-dev \
                               texinfo texlive texlive-fonts-extra \
                               screen wget libpcre2-dev
cd /usr/local/src
sudo wget https://cran.rstudio.com/src/base/R-4/R-4.1.2.tar.gz
sudo su
tar zxvf R-4.1.2.tar.gz
cd R-4.1.2
./configure --enable-R-shlib #--with-blas --with-lapack #optional
make
make install
cd ..
rm -rf R-4.1.2*
exit
cd

Further progress but still no cigar.

after messing around for a while I realized that the command

tar zxvf R-4.1.2.tar.gz

was not executing so I reissued it and got the R-4.1.2 directory.
I submitted the rest of the commands and things seemed to be going well but
then I got two errorn

make[3]: Entering directory '/usr/local/src/R-4.1.2/src/main'
cp: not writing through dangling symlink '/usr/local/lib/R/lib/libR.so'
make[3]: *** [Makefile:205: install-lib] Error 1
make[3]: Leaving directory '/usr/local/src/R-4.1.2/src/main'
make[2]: *** [Makefile:196: install] Error 2

& then

make[1]: Leaving directory '/usr/local/src/R-4.1.2/src'
make: *** [Makefile:95: install] Error 1
exit
tar (child): R-4.1.2.tar.gz: Cannot open: No such file or directory
tar (child): Error is not recoverable: exiting now
tar: Child returned status 2
tar: Error is not recoverable: exiting now
john@john:/usr/local/src$ 

It seems you have a conflicting symlink already in place, I would try deleting the entire usr/local/lib/R folder before trying again.

Also, I just checked and there are binaries available for Ubuntu 21.10 on CRAN so you could simply follow the official instructions to add the cran repository instead of compiling yourself.

https://cran.r-project.org/bin/linux/ubuntu

Getting closer eact time

make[1]: Leaving directory '/usr/local/src/R-4.1.2/tests'
exit
tar (child): R-4.1.2.tar.gz: Cannot open: No such file or directory
tar (child): Error is not recoverable: exiting now
tar: Child returned status 2
tar: Error is not recoverable: exiting now
bash: cd: R-4.1.2: No such file or directory
bash: ./configure: No such file or directory
make: *** No targets specified and no makefile found.  Stop.
make: *** No rule to make target 'install'.  Stop.
exit
tar (child): R-4.1.2.tar.gz: Cannot open: No such file or directory
tar (child): Error is not recoverable: exiting now
tar: Child returned status 2
tar: Error is not recoverable: exiting now

Blast it I checked CRAN yesterday and completely missed the binaries available for Ubuntu 21.10 on CRAN.

I'll give them a try
thanks

OOPS, just did an instal with CRAN and still get the error. I wonder a reinstall of RStudio might help?

Weird. I tried loading RStudio from an icon and got the same error but oading from a command in the terminal seems to work fine. I remain totally confused but at leastn it seems I have a working R + RStudio.

Thanks for all the help

It is likely that you have two versions of R installed, the one you compiled and the one you installed from the binary and RStudio is finding the former first.

Yes it seems so. It looks like I have a 4.0 version still installed but loading from the terminal seems to have sorted it out and R Studio is row finding 4.1.2.

Things seem to be working well until I get to

sudo wget https://cran.rstudio.com/src/base/R-4/R-4.1.2.tar.gz
sudo su
tar zxvf R-4.1.2.tar.gz

For some reason the R-4.1.2.tar.gz file is not unpacking.

root@john:/usr/local/src# cd /usr/local/src
sudo wget https://cran.rstudio.com/src/base/R-4/R-4.1.2.tar.gz
sudo su
tar zxvf R-4.1.2.tar.gz
--2022-01-14 11:01:47--  https://cran.rstudio.com/src/base/R-4/R-4.1.2.tar.gz
Resolving cran.rstudio.com (cran.rstudio.com)... 13.226.140.27, 13.226.140.42, 13.226.140.33, ...
Connecting to cran.rstudio.com (cran.rstudio.com)|13.226.140.27|:443... connected.
HTTP request sent, awaiting response... 200 OK
Length: 34009074 (32M) [application/x-gzip]
Saving to: ‘R-4.1.2.tar.gz’

R-4.1.2.tar.gz      100%[===================>]  32.43M  4.28MB/s    in 9.6s    

2022-01-14 11:01:57 (3.36 MB/s) - ‘R-4.1.2.tar.gz’ saved [34009074/34009074]

but there is no sign of the R-4.1.2 folder.

root@john:/usr/local/src# ls
R-4.1.2.tar.gz
root@john:/usr/local/src# 

Are you logged as root? If so, there is no need for sudo, also, can you show the console output of running just the "tar" line?