How to install Tidyverse on Ubuntu 16.04 and 17.04 - r

I'm running Ubuntu 16.04 [now 17.04: see note in bold below] and R 3.4.1. I installed the latter this morning, so I presume it's the latest version. I want to install Tidyverse, which I've spent many happy hours with under Windows. But when I do install.packages("tidyverse") , I get errors about unrecognized command line options to gcc. These start when the install hits the colorspace and munsell packages. I'll show an example at the end of this post, just for munsell.
I've not found anyone else who had exactly that problem on Ubuntu 16.04. But posts from people with similar problems suggest that my gcc might be a version that's too old to recognise the options -fstack-protector-strong and -Wdate-time.
Possible work-arounds that I've thought of:
1) Update Ubuntu to 16.10 or 17.04 in the hope that one of these has a suitable gcc. However, I'm hitting my lack of Ubuntu expertise here: in particular, it appears that I have to upgrade twice, once to 16.10 and then again to 17.04. I can't even make the system upgrade to 16.10: the steps recommended at https://wiki.ubuntu.com/YakketyYak/ReleaseNotes , "Upgrading from Ubuntu 16.04 LTS", don't find upgrades when I try them. Also, I don't know for sure whether either of those Ubuntus would have the right gcc.
Added the following day: Although my attempts to upgrade Ubuntu by following https://wiki.ubuntu.com/YakketyYak/ReleaseNotes did nothing yesterday, they did work today. Maybe a caching problem? So I now have Ubuntu 17.04. However, I still get the same errors when trying to install Tidyverse.
2) Find an older version of Tidyverse that doesn't need those compiler options.
3) Upgrade my Ubuntu's gcc. But I don't know whether that would nuke other software on my machine that expects an older gcc.
4) Install a new gcc just for Tidyverse, and somehow play with paths to fool the installer into calling it, perhaps by following the advice in https://askubuntu.com/questions/466651/how-do-i-use-the-latest-gcc-on-ubuntu . But that sounds risky.
5) Scrap Ubuntu and do all my work on Windows. I know people deride "Micro$oft", but at least with Windows, I don't waste a morning with Linux arcana and can do my job, which is R. This is feeling far too much like the priests with their incantations in https://people.dsv.su.se/~jpalme/s1/hoare.pdf , "Software Design: a Parable". Just saying...
Any suggestions from someone who has actually done this with these versions of R and Ubuntu?
Here's an install that failed:
`> install.packages("munsell")
Installing package into ‘/home/popx/R/x86_64-pc-linux-gnu-library/3.4’
(as ‘lib’ is unspecified)
also installing the dependency ‘colorspace’
trying URL 'https://cran.rstudio.com/src/contrib/colorspace_1.3-2.tar.gz'
Content type 'application/x-gzip' length 293433 bytes (286 KB)
==================================================
downloaded 286 KB
trying URL 'https://cran.rstudio.com/src/contrib/munsell_0.4.3.tar.gz'
Content type 'application/x-gzip' length 97244 bytes (94 KB)
==================================================
downloaded 94 KB
* installing *source* package ‘colorspace’ ...
** package ‘colorspace’ successfully unpacked and MD5 sums checked
** libs
gcc -std=gnu99 -I/usr/share/R/include -DNDEBUG -fpic -g -O2 -fstack-protector-strong -Wformat -Werror=format-security -Wdate-time -D_FORTIFY_SOURCE=2 -g -c colorspace.c -o colorspace.o
gcc: error: unrecognized command line option '-fstack-protector-strong'
gcc: error: unrecognized command line option '-Wdate-time'
/usr/lib/R/etc/Makeconf:159: recipe for target 'colorspace.o' failed
make: *** [colorspace.o] Error 1
ERROR: compilation failed for package ‘colorspace’
* removing ‘/home/popx/R/x86_64-pc-linux-gnu-library/3.4/colorspace’
Warning in install.packages :
installation of package ‘colorspace’ had non-zero exit status
ERROR: dependency ‘colorspace’ is not available for package ‘munsell’
* removing ‘/home/popx/R/x86_64-pc-linux-gnu-library/3.4/munsell’
Warning in install.packages :
installation of package ‘munsell’ had non-zero exit status
The downloaded source packages are in
‘/tmp/RtmpQ8FW70/downloaded_packages’
Warning message:
R graphics engine version 12 is not supported by this version of RStudio. The Plots tab will be disabled until a newer version of RStudio is installed.

In some cases I find that I need to install the Ubuntu packages. To install the Tidyverse I added
sudo apt-get install r-cran-curl r-cran-openssl r-cran-xml2
After installing these packages, I could install the Tidyverse.

I run into the same problem, using elementary loki, based on ubuntu 16.04. Reading the output, I realized there was a very informative error message, that looked like this
------------------------- ANTICONF ERROR ---------------------------
Configuration failed because openssl was not found. Try installing:
* deb: libssl-dev (Debian, Ubuntu, etc)
* rpm: openssl-devel (Fedora, CentOS, RHEL)
* csw: libssl_dev (Solaris)
* brew: openssl#1.1 (Mac OSX)
If openssl is already installed, check that 'pkg-config' is in your
PATH and PKG_CONFIG_PATH contains a openssl.pc file. If pkg-config
is unavailable you can set INCLUDE_DIR and LIB_DIR manually via:
R CMD INSTALL --configure-vars='INCLUDE_DIR=... LIB_DIR=...'
So I followed each prompt, installing the required deb, which came up to
sudo apt-get install libssl-dev libxml2-dev libcurl4-openssl-dev
and it worked, after I had already tried installing the cran packages listed above, without adding the new repositories.

I believe had a similar problem trying to install the tidyverse package.
Being reasonably new to Linux and a complete rookie to R, I followed the Ubuntu installation intructions on the CRAN Project's homepage. When I installed R, I deliberately skipped installation of the r-base-dev package, as it said it was intended for "package maintainers". I didn't really read the latter part or understand the necessity for compiling packages myself.
Anyway, installing r-base-dev package, and allowed me to install the Tidyverse package without problems. The complete steps to get it to work should be something like below. In terminal do the following steps (Step 1-3 may or may not be necessary, but I've added them just in case):
Add deb https://<my.favorite.cran.mirror>/bin/linux/ubuntu artful/ in your /etc/apt/sources.list file, replacing by the actual URL of your favorite CRAN mirror. See https://cran.r-project.org/mirrors.html for the list of CRAN mirrors.
Add the repository key to your system:
sudo apt-key adv --keyserver keyserver.ubuntu.com --recv-keys E084DAB9
An alternate method can be used by retrieving the key with
gpg --keyserver keyserver.ubuntu.com --recv-key E084DAB9
and then feed it to apt-key with
gpg -a --export E084DAB9 | sudo apt-key add -
To install the complete R system, use
sudo apt-get update
sudo apt-get install r-base
Then comes the step I missed, that proved crucial to be able to compile the packages within the Tidyverse package, namely installing the r-base-dev package:
sudo apt-get install r-base-dev
Then in RStudio execute the package installation command:
install.packages(tidyverse)
Hopefully this will work for you as well. Read the installation guide on the CRAN Projects homepages for further about the installation procedure.

Add CRAN repo
https://cloud.r-project.org/bin/linux/ubuntu/
sudo add-apt-repository ppa:c2d4u.team/c2d4u4.0+
sudo apt-get r-cran-tidyverse
Then you're installing tidyverse from binary rather than compiling 100 times quicker.

Related

R ERROR: dependencies ‘xml2’, ‘httr’ are not available for package (Linux Mint 20.1)

I did not quite know where this belongs exactly, so I decided to post this here on stack overflow.
I recently had package issues with R and R-Studio on Linux Mint 20.1, where I always recieved dependency errors when installing packages like plotly and tidyverse. Therefore, in order to test if my system was responsible I live booted a fresh Linux Mint USB and installed R and R-Studio the following way:
sudo apt update
sudo apt dist-upgrade
sudo apt install r-base
Then download R-Studio from here and installed it like:
sudo apt-get install gdebi-core
# Install R-Studio with gdebi
sudo gdebi rstudio-1.2.5042-amd64.deb
Then, I opened RStudio by typing rstudio in the terminal. Inside RStudio I tried to install the package tidyverse by install.packages("tidyverse") which resulted in some dependency errors like:
ERROR: dependencies ‘xml2’, ‘httr’ are not available for package ‘rvest’
* removing ‘/home/mint/R/x86_64-pc-linux-gnu-library/3.6/rvest’
* installing *source* package ‘tibble’ ...
The solution was to use the command, suggested in the r-lib issue by #fredaas:
sudo apt install build-essential libcurl4-gnutls-dev libxml2-dev libssl-dev
By using this command I was able to resolve the issue and install every package I required flawlessly.
I am sorry if this does not belong here but I hope I can help someone saving hours of troubleshooting. This issues is maybe caused by Linux Mint or the most recent R Version 4.0.3 so I was not sure where to share my results.

Installing R `sf` and `RPostgres` packages on Unbuntu 18.04.4

Desire is to installed R {sf} and {RPostgres} packages on Ubuntu 18.04.4.
Trying:
R$> install.packages("sf")
configure: error: gdal-config not found or not executable.
Some SO searching (eg https://stackoverflow.com/a/49181048/2802810) suggests this:
sh$> sudo apt-get install libgdal-dev
The following packagess have unmet dependencies: libpq-dev :
Depends: libpq5 (= 10.12-0Ubuntu0.18.04.1) but 12.3-1.pgdg18.04+1 is
to be installed E: Unable to correct problems, you have broken
packages.
I also need libpq-dev for R {RPostgres}.
You may want to add PPA, depending on your R version.
https://launchpad.net/~marutter/+archive/ubuntu/c2d4u
https://launchpad.net/~marutter/+archive/ubuntu/c2d4u3.5
https://launchpad.net/~c2d4u.team/+archive/ubuntu/c2d4u4.0+
After adding PPA, you can install using sudo apt install r-cran-sf and sudo apt install r-cran-rpostgres
OKaaaay. The box I'm working in didn't have a Postgres repo installed (https://www.postgresql.org/download/linux/ubuntu/). Never libpq libs and that was all it needed.

How can I install a R package on a offline Debian machine?

I have an Debian VM which is not connected to internet. Yet, I can still scp any file from my local machine which does have internet connection. To provide a little bit context, I am trying to host an shiny app on the VM.
I can still install an old version of R 3.1.1 with the "apt-get" command:
sudo apt-get update
sudo apt-get install r-base
sudo apt-get install r-base-dev
Yet, still can't find the "shiny" package when check the list:
sudo apt-cache search "^r-.*" | sort
So, I am thinking whether I could just scp the "shiny.tar.gz" to the VM and install the package locally? How could I install any R package offline?
I have tried somethings like:
install.packages('/home/mli/R/dir_pkg/shiny/shiny_0.13.2.tar.gz', repos = NULL, type = "source")
Yet, it didn't go through and error message as below:
Installing package into ‘/usr/local/lib/R/site-library’
(as ‘lib’ is unspecified)
Error in type == "both" :
comparison (1) is possible only for atomic and list types
Calls: install.packages
Execution halted
Then, I tried it with another "R CMD":
R CMD INSTALL /home/mli/R/dir_pkg/shiny/shiny_0.13.2.tar.gz
I got error message telling me that dependencies is missing:
* installing to library ‘/home/mli/R/x86_64-pc-linux-gnu-library/3.1’
ERROR: dependencies ‘httpuv’, ‘mime’, ‘jsonlite’, ‘xtable’, ‘digest’, ‘htmltools’, ‘R6’ are not available for package ‘shiny’
* removing ‘/home/mli/R/x86_64-pc-linux-gnu-library/3.1/shiny’
How can I successfully install shiny package from source? Should I go ahead to install all dependencies and dependencies of dependencies first?
Shiny has a few package dependencies, and "R CMD INSTALL" won't find them for you, so you need to get them manually. According to the description of shiny, it's dependencies are:
'Rcpp’, ‘httpuv’, ‘mime’, ‘jsonlite’, ‘xtable’, ‘digest’, ‘htmltools’, ‘R6’.
So first, get the packages from cran (below are current versions, but they do change over time. Note below is for the computer connected to the internet, you'll need to scp these to the offline computer before continuing):
wget https://cran.r-project.org/src/contrib/Rcpp_0.12.4.tar.gz
wget https://cran.r-project.org/src/contrib/httpuv_1.3.3.tar.gz
wget https://cran.r-project.org/src/contrib/mime_0.4.tar.gz
wget https://cran.r-project.org/src/contrib/jsonlite_0.9.19.tar.gz
wget https://cran.r-project.org/src/contrib/digest_0.6.9.tar.gz
wget https://cran.r-project.org/src/contrib/htmltools_0.3.5.tar.gz
wget https://cran.r-project.org/src/contrib/R6_2.1.2.tar.gz
wget https://cran.r-project.org/src/contrib/shiny_0.13.2.tar.gz
Then go through them in that same order with R CMD INSTALL. eg:
R CMD INSTALL Rcpp_0.12.4.tar.gz
Once all the dependencies are there, R CMD INSTALL should let you install shiny.
To install some package-offline on Debian you can use apt-offline :
apt-offline can fully update and upgrade an APT based distribution without connecting to the network, all of it transparent to APT.
apt-offline can be used to generate a signature on a machine (with no network). This signature contains all download information required for the APT database system. This signature file can be used on another machine connected to the internet (which need not be a Debian box and can even be running windows) to download the updates. The downloaded data will contain all updates in a format understood by APT and this data can be used by apt-offline to update the non-networked machine.
Install apt-offline on the offline os (Debian) then type the following command (to import missing keys) :
sudo apt-key exportall | sudo gpg --no-default-keyring --import --keyring /etc/apt/trusted.gpg
Then you need to get the signature of your_package_name:
apt-offline set debian-install.sig --install-packages your_package_name
Next step ,Upload debian-install.sig to the on-line system and download required files.
apt-offline get debian-install.sig --bundle debian-install.zip
Upload debian-install.zip file to the off-line system, install it using apt-offline utility to update APT database.
sudo apt-offline install debian-install.zip
install the specified packages your_package_name :
sudo apt-get install your_package_name
You can download your package using windows machine tuto
You are in a pickle. The R package mechanism expects you to be connected to get dependencies. That said, you can get some help:
R> AP <- available.packages(contrib.url(options("repos")$repos[1]))
R> revs <- tools::package_dependencies("shiny", AP, recursive=TRUE)[[1]]
R> revs
[1] "methods" "utils" "httpuv" "mime"
[5] "jsonlite" "xtable" "digest" "htmltools"
[9] "R6" "Rcpp" "tools" "stats"
R>
You can now look into AP again and feed this into download.packages().
Also, several (all ?) of these are in a newer Debian distro so you could use apt-get in download-mode (maybe using apt-offline as suggested in the other question).
Lastly, we do offer a Docker container for shiny so if you use that on your VM you don't need anything else.
sudo apt-get update
sudo apt-get install r-cran-digest
I can`t belive that it was so easy. I spent a long time searching and got only bad answers. This commands just solve everything.
I used it on trisquel
after checking all the answers on stackoverflow, I am not able to find exactly how to to install r-base on Debian/linux system. So, I have tried myself and able to run by below steps:
Run below command on internet working Linux machine in a custom folder.
apt-get download r-base r-base-core r-recommended libmpfr6 libisl19 cpp cpp-8 cpp-4 gcc cpp-8 binutils-common libbinutils binutils-x86-64-linux-gn gfortran linux-libc-dev g++ g++-8 libstdc make dpkg-dev perl-base perl-modules-5.28 libperl5.28 ibgdbm-compat4 zip unzip libpaper-utils xdg-utils libblas3 libblas.so.3 libcairo2 libcurl4 libgfortran5 libglib2.0-0 libice6 libicu63 libjpeg62-turbo liblapack3 liblapack.so.3 libpango-1.0-0 libpangocairo-1.0-0 libpng16-16 libsm6 libtcl8.6 libtiff5 libtk8.6 libx11-6 libxext6 libxss1 libxt6 ucf libfontconfig1 libfreetype6 libpixman-1-0 libxcb-render0 libxcb-shm0 libxcb1 libxrender1 libgssapi-krb5-2 libk5crypto3 libkrb5-3 libldap-2.4-2 libnghttp2-14 libpsl5 librtmp1 libssh2-1 libbsd0 x11-common fontconfig libfribidi0 libthai0 libcairo2:amd64 libfontconfig1 libfreetype6 libpango-1.0-0:amd64 libpangoft2-1.0-0 fontconfig-config libkeyutils1 libkrb5support0 libkeyutils1 libkrb5support0 libkeyutils1 libkrb5support0 libsasl2-2 libldap-common fontconfig-config libharfbuzz0b libpaper1 libsasl2-modules-db libthai-data libdatrie1 libwebp6 libjbig0 libxft2 libx11-data libxau6 libxdmcp6 fonts-dejavu-core ttf-bitstream-vera fonts-liberation libgraphite2-3 lsb-base sensible-utils r-cran-boot r-cran-cluster r-cran-foreign r-cran-kernsmooth r-cran-lattice r-cran-mgcv r-cran-nlme r-cran-rpart r-cran-survival r-cran-mass r-cran-class r-cran-nnet r-cran-spatial r-cran-codetools r-cran-matrix
This will create debian files inside the folder.
`Execute tar -zcf folder.tar.gz folder`
Copy this folder.tar.gz in offline computer and execute below command after going inside the folder.
dpkg -i *
Now check R in your system by typing
R --version

unable to install rvest package

I need to install rvest package for R version 3.1.2 (2014-10-31)
I get these errors:
checking whether the C++ compiler supports the long long type... no
*** stringi cannot be built. Upgrade your C++ compiler's settings
ERROR: configuration failed for package ‘stringi’
* removing ‘/usr/local/lib64/R/library/stringi’
ERROR: dependency ‘stringi’ is not available for package ‘stringr’
* removing ‘/usr/local/lib64/R/library/stringr’
ERROR: dependency ‘stringr’ is not available for package ‘httr’
* removing ‘/usr/local/lib64/R/library/httr’
ERROR: dependency ‘stringr’ is not available for package ‘selectr’
* removing ‘/usr/local/lib64/R/library/selectr’
ERROR: dependencies ‘httr’, ‘selectr’ are not available for package ‘rvest’
* removing ‘/usr/local/lib64/R/library/rvest’
Any ideas on how I could install R package rvest?
My system is Ubuntu 14.04 with R:3.2.3, and I had the same problem.
Then I checked err meg and tried to install library of libcurl4-openssl-dev and libxml2-dev:
sudo apt-get install libcurl4-openssl-dev
sudo apt-get install libxml2-dev
After installed, install.packages("rvest") was successful.
I needed dependencies such as Rcurl, XML, rvest, xml2, when I was trying to install tidyverse, DESeq2, RUVSeq in Rstudio Version 1.1.456 on a fresh installed Ubuntu 18.04. Anyway, there were a bunch of missing dependencies. This answer might fit better as a comment for Ubuntu 18.04, but I don't have that many reputation. So just trying to make a summary of solutions works for Ubuntu 18.04 here.
In the terminal, run:
sudo apt-get install libcurl4-openssl-dev libssl-dev
sudo apt-get install libxml2-dev
Then within Rstudio,
install.packages("xml2")
install.packages("rvest")
install.packages("tidyverse") # might need other dependencies installed in Rstudio
Got tidyverse!
In the terminal:
sudo apt-get install libmysqlclient-dev ## for RMySQL
Then within the Rstudio
source("https://bioconductor.org/biocLite.R")
biocLite("DESeq2")
biocLite('RUVSeq') ## might have messages as following
installation path not writeable, unable to update packages: cluster, foreign, MASS, Matrix, mgcv, nlme, survival
In the terminal:
sudo R ## give R the root permission
## in the R session within the terminal
pks <- c('cluster', 'foreign', 'MASS', 'Matrix', 'mgcv', 'nlme', 'survival')
install.packages(pks)
q()
That's my own experience. Hope this one has a good Generalizability.
I was able to build the stringi package as this:
install.packages('stringi', configure.args='--disable-cxx11')
My answer is definitely late to this question. Nevertheless, somebody may find it useful.
I run into the same problem so I run this command on the shell:
sudo apt-get upgrade pkg-config
It worked for me.

How to solve the error " missing required header GL/gl.h" while installing the Package mvoutlier in R?

I am trying to install the package mvoutlier but following error occurs during installation:
install.packages("mvoutlier")
configure: error: missing required header GL/gl.h
ERROR: configuration failed for package ‘rgl’
* removing ‘/home/sam/R/x86_64-pc-linux-gnu-library /2.15/rgl’
ERROR: dependency ‘rgl’ is not available for package ‘compositions’
* removing ‘/home/sam/R/x86_64-pc-linux-gnu-library/2.15/compositions’
ERROR: dependency ‘compositions’ is not available for package ‘mvoutlier’
* removing ‘/home/sam/R/x86_64-pc-linux-gnu-library/2.15/mvoutlier’
After that I have install the rgl package successfully, then I tried to install the compositions package then the again same error occurs. Then I have again tried to install the mvoutlier package the same error occurs.
Can anyone let me know how I can resolve this problem. Thanking you in advance.
I suspect you are running Ubuntu 12.04.I think you're going to find that this works for the GL/gl.h problem:
install these at the regular old terminal, ie pretend R doesn't exist for now:
libglu1-mesa-dev freeglut3-dev mesa-common-dev
You might get the following error later (in R) because of a tcl b****/gripe/complaint:
Error in structure(.External(.C_dotTcl, ...), class = "tclObj") :
[tcl] can't find package BWidget.
To fix this problem, if you have it:
sudo apt-get install bwidget
These are not R problems. They are OS problems!
I ran into the same issue in between others on a Ubuntu based Linux distro (Linux Mint). Here I will share the worklog I'd done to fix it.
The full fix was:
apt-get install libx11-dev mesa-common-dev libglu1-mesa-dev
Worklog
The first error was related to missing devel libraries of X11:
configure: error: X11 not found but required, configure aborted.
I fixed it installing:
apt-get install libx11-dev
However, after fix the issue, I felt into a new one like this one:
configure: error: missing required header GL/gl.h
ERROR: configuration failed for package ‘rgl’
I checked the library on the repository:
# dpkg -S /usr/include/GL/gl.h
dpkg-query: no path found matching pattern /usr/include/GL/gl.h
To fix this issue, install :
apt-get install mesa-common-dev
Then, I was prompt by a new error:
configure: error: missing required header GL/glu.h
To fix the issue, install the libglu1 devel libraries:
apt-get install libglu1-mesa-dev
configure: error: missing required header GL/gl.h
normally means you haven't installed the -dev version of a package, in this case GL.
On my system, GL/gl.h is owned by mesa-common-dev
$ dpkg -S /usr/include/GL/gl.h
mesa-common-dev: /usr/include/GL/gl.h
which would have been installed with apt-get install mesa-common-dev or via some GUI magic.
On Ubuntu 16.04, I solved this problem (during rgl package installation) with sudo apt-get install libglu1-mesa-dev
the current fedora package manager will fail to find these libraries as shown. Instead you need to do
sudo dnf install mesa-libGL-devel mesa-libGLU-devel
Based on the work breakdown by 3manuek, I figured only the libglu1-mesa-dev library was needed in ubuntu 16.04 LTS, and it worked.
On, RHEL, sudo yum install mesa-libGLU-devel worked.
I encountered an equivalent problem when testing a package that required 'rgl' on Travis. The problem is that the operating system lacks the necessary GL files on which the 'rgl' package draws.
A thread at R-forge offers the ingenious solution of running apt-get install r-cran-rgl, which will pull in any of the GL dependencies not already present on the operating system. This seems simpler than second-guessing which specific dependency is missing, and it remains possible to install a more recent version of 'rgl' if required.

Resources