Error: 32:1 unexpected '}' after installing base R

Hi, I have installed R 4.3.2 Eye Holes in an Ubuntu server (20.04.06 LTS), as a first step for the installation of RStudio Server (free version) and Posit Connect (licensed version). I followed these instructions posit at co/download/rstudio-server/.
In particular, I used these commands cran dot rstudio at com/bin/linux/ubuntu/

# update indices
sudo apt update -qq
# install two helper packages we need
sudo apt install --no-install-recommends software-properties-common dirmngr
# add the signing key (by Michael Rutter) for these repos
# To verify key, run gpg --show-keys /etc/apt/trusted.gpg.d/cran_ubuntu_key.asc 
# Fingerprint: E298A3A825C0D65DFD57CBB651716619E084DAB9
wget -qO- https://cloud.r-project.org/bin/linux/ubuntu/marutter_pubkey.asc | sudo tee -a /etc/apt/trusted.gpg.d/cran_ubuntu_key.asc
# add the R 4.0 repo from CRAN -- adjust 'focal' to 'groovy' or 'bionic' as needed
sudo add-apt-repository "deb https://cloud.r-project.org/bin/linux/ubuntu $(lsb_release -cs)-cran40/"

sudo apt install --no-install-recommends r-base

Note that these instructions are contradicting these other Posit instructions Posit - Install R - Posit Documentation, where a download and installation of a .deb file is advised.

apt install completes the installation of R 4.3.2 without errors. However, when I launch R from the console, I get the following error message Error: 32:1 unexpected '}' , which is puzzling.
If I open a session in RStudio Server, I get the same error, but I can also see a preloaded r object in the environment with an URL with "https://cloud.r-project at org" as string value.

Could you help to solve this base R installation problem, please?

This seems like a problem with your startup files, look at the content of your Rprofile.site and .Rprofile files, one of them is executing invalid R code at the start of your R session.

Hi, I didn't detect anything unusual in the Rprofile.site and .Rprofile files.
I am sharing the steps that I followed to fix this problem:

  • uninstall R completely:
dpkg -l | grep ^ii | awk '$2 ~ /^r-/ { print $2 }' | xargs apt-get remove --purge -y
  • check that there are no remaining installations of R
which R
R --version

Install R, following the Posit-endorsed way of installing R in Linux

apt-get update
apt-get install gdebi-core
export R_VERSION=4.3.2
curl -O https://cdn.rstudio.com/r/ubuntu-2004/pkgs/r-${R_VERSION}_1_amd64.deb
gdebi r-${R_VERSION}_1_amd64.deb

Do not follow these steps.
-check that only one version of R is installed under /opt/R

  • delete any previous folders if needed

-verify the route of the R installation and the version of R

/opt/R/${R_VERSION}/bin/R --version 

which R
R --version
R -e R.version
  • create symlinks
ln -s /opt/R/${R_VERSION}/bin/R /usr/local/bin/R
ln -s /opt/R/${R_VERSION}/bin/Rscript /usr/local/bin/Rscript

It may be needed to remove the symlinks before creating them when you update the version of R.

unlink /usr/local/bin/R
unlink /usr/local/bin/Rscript

If you can't still get output for R --version or just execute R typing R,
verify this file

nano /etc/environment 

The `/etc/environment` file [normally contains only this line](https://askubuntu.com/questions/866161/setting-path-variable-in-etc-environment-vs-profile):

```shell
PATH="/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games:/snap/bin"

Following all these steps, I managed to fix my issue. I am leaving these notes here to help the community, thanks.

This topic was automatically closed 7 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.