Score:2

Installing R and RStudio in Lubuntu 20.04

gs flag

I wanted to install R with Rstudio to start learning, but I found many problems in the way, I'll explain as much as i can below.

So I went to the CRAN Project website https://cran.r-project.org/ and followed their instructions to install R on my laptop.

# update indices
apt update -qq
# install two helper packages we need
apt install --no-install-recommends software-properties-common dirmngr
# import the signing key (by Michael Rutter) for these repo
apt-key adv --keyserver keyserver.ubuntu.com --recv-keys E298A3A825C0D65DFD57CBB651716619E084DAB9
# add the R 4.0 repo from CRAN -- adjust 'focal' to 'groovy' or 'bionic' as needed
add-apt-repository "deb https://cloud.r-project.org/bin/linux/ubuntu $(lsb_release -cs)-cran40/"

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

After that, I go to RStudio webpage and download rstudio-server-1.4.1717-amd64.deb. First I tried to install it with the GUI but the following message appeared:

GPG error: https://cloud.r-project.org/bin/linux/ubuntu focal-cran40/ InRelease: The following signatures couldn't be verified because the public key is not available: NO_PUBKEY 51716619E084DAB9

The repository 'https://cloud.r-project.org/bin/linux/ubuntu focal-cran40/ InRelease' is not signed.

Updating from such a repository can't be done securely, and is therefore disabled by default.

See apt-secure(8) manpage for repository creation and user configuration details.

Then I tried to install it with sudo apt install ./rstudio-server-1.4.1717-amd64.deb and the following happened:

Note, selecting 'rstudio' instead of './rstudio-1.4.1717-amd64.deb'
Some packages could not be installed. This may mean that you have
requested an impossible situation or if you are using the unstable
distribution that some required packages have not yet been created
or been moved out of Incoming.
The following information may help to resolve the situation:

The following packages have unmet dependencies:
 rstudio : Depends: libclang-dev but it is not going to be installed
E: Unable to correct problems, you have held broken packages.

Finally, as I found many tutorials installing with gdebi, I gave it another shot:

gdebi rstudio-1.4.1717-amd64.deb 

Which yields:

Reading package lists... Done
Building dependency tree        
Reading state information... Done
Reading state information... Done
This package is uninstallable
Cannot install 'libclang-dev'

So apparently something is going on with libclang-dev, I tried to install it:

sudo apt install libclang-dev

Reading package lists... Done
Building dependency tree       
Reading state information... Done
Some packages could not be installed. This may mean that you have
requested an impossible situation or if you are using the unstable
distribution that some required packages have not yet been created
or been moved out of Incoming.
The following information may help to resolve the situation:

The following packages have unmet dependencies:
 libclang-dev : Depends: libclang-10-dev (>= 10~) but it is not going to be installed
E: Unable to correct problems, you have held broken packages.

So I tried to install libclang-10-dev but it takes me to another dependency problem similar to the one showed here. I don't think this chain of problems is going to end soon to do it manually.

The last pieces of information I can give you:

When I run rstudio it says command not found.

And now when I do apt update I get the same message as above starting with the "GPG"

The final piece of information I can provide is that when I run R in the command line, I can use R-language from there.

If you happen to know anything I can do to fix this, I'd appreciate it.

wizardpurple avatar
cn flag
Are you sure you added the signing key and didn't accidentally miss that step? Also, you can get install rstudio-server using the r-base/r-base-dev packages that are already in the default Ubuntu repositories. You don't need to install from r-cran. ```apt search r-base```
nico_so avatar
gs flag
Hi, yes I am sure, I just checked ´history´ and I did everything. To install from the default repos, should I undo anything off the above? And R is actually working in the shell, I cannot install RStudio.
wizardpurple avatar
cn flag
yes, you would want to sort of go in reverse of the install order. Remove the added repository using ```add-apt-repository -r``` instead of ```add-apt-repository``` to from the above steps. Delete the key ```apt-get del```. Then update your repos. Finally, I think you'd need to use a tool like aptitude to downgrade the R packages, but since you got everything working you probably want to simply keep it as is and focus on using R instead.
nico_so avatar
gs flag
Thank you for your help! I think it could pay off later if do the fix, so thanks for the details.
Score:0
bt flag

https://www.geeksforgeeks.org/how-to-install-r-studio-on-windows-and-linux/#:~:text=Installing%20R%20Studio%20on%20Ubuntu&text=Step%201%3A%20Open%20terminal%20(Ctrl,2%3A%20Update%20the%20package's%20cache.&text=Step%203%3A%20Install%20R%20environment.&text=Step%204%3A%20Check%20R%20installation%20by%20using%20the%20following%20command.

plz chk this this will work

Score:0
gs flag

To resolve the installation problem, I found the following:

https://stackoverflow.com/questions/67383617/unable-to-install-rstudio-cannot-install-libclang-dev

You first need to install aptitude

sudo apt install aptitude

Then you can run

sudo aptitude install clang

Say No to the first question, Yes to the second.

Then you can go and install RStudio with gdebi.

mangohost

Post an answer

Most people don’t grasp that asking a lot of questions unlocks learning and improves interpersonal bonding. In Alison’s studies, for example, though people could accurately recall how many questions had been asked in their conversations, they didn’t intuit the link between questions and liking. Across four studies, in which participants were engaged in conversations themselves or read transcripts of others’ conversations, people tended not to realize that question asking would influence—or had influenced—the level of amity between the conversationalists.