cannot install R tseries, quadprog ,xts packages in Linux - r

I am using R version 3.4.0
I'm trying to install tseries package on linux machine:
install.packages('https://cran.cnr.berkeley.edu/src/contrib/tseries_0.10-42.tar.gz',dependencies = TRUE,repos = NULL,type ="source")
It gives error:
ERROR: compilation failed for package 'xts'
* removing '/usr/lib64/R/library/xts'
ERROR: dependency 'xts' is not available for package 'TTR'
* removing '/usr/lib64/R/library/TTR'
ERROR: dependencies 'xts', 'TTR' are not available for package 'quantmod'
* removing '/usr/lib64/R/library/quantmod'
ERROR: dependencies 'quadprog', 'quantmod' are not available for package 'tseries'
* removing '/usr/lib64/R/library/tseries'
1: In install.packages("tseries", dependencies = TRUE) :
installation of package 'quadprog' had non-zero exit status
2: In install.packages("tseries", dependencies = TRUE) :
installation of package 'xts' had non-zero exit status
3: In install.packages("tseries", dependencies = TRUE) :
installation of package 'TTR' had non-zero exit status
4: In install.packages("tseries", dependencies = TRUE) :
installation of package 'quantmod' had non-zero exit status
5: In install.packages("tseries", dependencies = TRUE) :
installation of package 'tseries' had non-zero exit status
Then I tried installing quadprog using:
install.packages('https://cran.cnr.berkeley.edu/src/contrib/quadprog_1.5-5.tar.gz',dependencies = TRUE,repos = NULL,type ="source")
It gives error :
/usr/bin/ld: cannot find -lgfortran
collect2: error: ld returned 1 exit status
make: *** [quadprog.so] Error 1
ERROR: compilation failed for package 'quadprog'
* removing '/usr/lib64/R/library/quadprog'
Please help what should i do. I'm facing hard time in installing these packages.
I have installed R using :
sudo yum -y install R-core R-devel
I tried installing gfortran using : yum install gcc-gfortran
It says :Package gcc-gfortran-4.4.7-18.el6.x86_64 already installed and latest version
Nothing to do

The problem here is that the Fortran compiler (gfortran) and the GCC compiler driver (gcc) are out of sync: gfortran is version 4.4.7, gcc is version 4.7.2. This means that they use different directories to store there files, and gcc is unable to locate the libgfortran.so symbolic link installed by the gcc-gfortran package.
The solution is to bring these two compilers to the same version. This can be achieved by adjusting the PATH variable (based on other discussions, gcc is not referring to /usr/bin/gcc here), deinstalling the software collection that provides this gcc command (using yum remove devtoolset-1.1-gcc), or installing the Fortran component for the same software collection, using yum install devtoolset-1.1-gcc-gfortran.
My best guess is that your devtoolset-1.1-gcc package comes from this repository:
https://people.centos.org/tru/devtools-1.1/6/x86_64/RPMS/
So you could use the gfortran package from there, too (and pick the c++ package as well, to avoid a similar problem).

After spending quite some time with the same error, the only solution that worked for me was to re-install all R components.
For completness, what I did was to remove all R components with:
dpkg -l | grep ^ii | awk '$2 ~ /^r-/ { print $2 }' | sudo xargs apt-get remove --purge -y (got it from here)
and re-install R again: sudo apt-get install r-base r-base-dev

I fixed this by reinstalling R from source using:
make install rhome=/usr

Related

Trying to get Tidyverse installed in Linux mint 20.2

I've been working on getting RStudio to open on and off for the last few days, finally got it running and started installing packages. Readr installed fine but tidyverse refuses to install.
/usr/bin/ld: /usr/local/lib/libcrypto.a(v3_genn.o): relocation R_X86_64_PC32 against symbol `GENERAL_NAME_it' can not be used when making a shared object; recompile with -fPIC
/usr/bin/ld: final link failed: bad value
collect2: error: ld returned 1 exit status
make: *** [/usr/share/R/share/make/shlib.mk:6: openssl.so] Error 1
ERROR: compilation failed for package ‘openssl’
* removing ‘/home/william/R/x86_64-pc-linux-gnu-library/3.6/openssl’
Warning in install.packages :
installation of package ‘openssl’ had non-zero exit status
ERROR: dependency ‘openssl’ is not available for package ‘ids’
* removing ‘/home/william/R/x86_64-pc-linux-gnu-library/3.6/ids’
Warning in install.packages :
installation of package ‘ids’ had non-zero exit status
ERROR: dependency ‘openssl’ is not available for package ‘httr’
* removing ‘/home/william/R/x86_64-pc-linux-gnu-library/3.6/httr’
Warning in install.packages :
installation of package ‘httr’ had non-zero exit status
ERROR: dependency ‘httr’ is not available for package ‘gargle’
* removing ‘/home/william/R/x86_64-pc-linux-gnu-library/3.6/gargle’
Warning in install.packages :
installation of package ‘gargle’ had non-zero exit status
ERROR: dependency ‘httr’ is not available for package ‘rvest’
* removing ‘/home/william/R/x86_64-pc-linux-gnu-library/3.6/rvest’
Warning in install.packages :
installation of package ‘rvest’ had non-zero exit status
ERROR: dependencies ‘gargle’, ‘httr’ are not available for package ‘googledrive’
* removing ‘/home/william/R/x86_64-pc-linux-gnu-library/3.6/googledrive’
Warning in install.packages :
installation of package ‘googledrive’ had non-zero exit status
ERROR: dependencies ‘gargle’, ‘googledrive’, ‘httr’, ‘ids’ are not available for package ‘googlesheets4’
* removing ‘/home/william/R/x86_64-pc-linux-gnu-library/3.6/googlesheets4’
Warning in install.packages :
installation of package ‘googlesheets4’ had non-zero exit status
ERROR: dependencies ‘googledrive’, ‘googlesheets4’, ‘httr’, ‘rvest’ are not available for package ‘tidyverse’
* removing ‘/home/william/R/x86_64-pc-linux-gnu-library/3.6/tidyverse’
Warning in install.packages :
installation of package ‘tidyverse’ had non-zero exit status
The downloaded source packages are in
‘/tmp/RtmpyoCTNu/downloaded_packages’
To fix this I've tried suggestions from two places:
The first option was 'sudo apt install libcurl4-openssl-dev libssl-dev libxml2-dev'
from this website: https://blog.zenggyu.com/en/post/2018-01-29/installing-r-r-packages-e-g-tidyverse-and-rstudio-on-ubuntu-linux/
The second this was 'sudo apt-get install r-base-dev xml2 libxml2-dev libssl-dev libcurl4-openssl-dev unixodbc-dev'
from the rstudio community page: https://community.rstudio.com/t/cant-install-tidyverse/29293
A third option I found that is too advanced for me without guidance is this:
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=...'
I'm sure I'm doing something wrong. I think something may not be in the proper place or is linked to the wrong location. Any assistance would be greatly appreciated.
(Also,for reference, this is the first time I've used linux so please dumb answers down as much as possible)
I've now gotten this to work. By looking at the error messages I found the dependencies that need to be installed before tidyverse can be installed (and function).
It is preferable but not necessary to get the latest version of R installed. I followed the steps in this tutorial:
https://linuxconfig.org/how-to-install-rstudio-on-ubuntu-20-04-focal-fossa-linux
In the interest of putting everything in one place, I'll put the steps here:
Step 1:
$ sudo apt update
$ sudo apt -y install r-base gdebi-core
Step 2: Install Rstudio from their website
Step 3: For this step, make sure you're in the folder that has the file downloaded, for me that was in downloads
$ sudo gdebi rstudio-1.2.5019-amd64.deb
Step 4: Open Rstudio
To get tidyverse to work, my error messages were all about non-zero exit statuses. What I did was to go through, find the packages that weren't properly installing, and manually install them.
My first problem was with curl. I tried installing it in Rstudio first. When I got an error, I went into terminal and installed it with
sudo apt-get install libcurl4-openssl-dev
If openssl refuses to install try:
sudo apt-get install libssl-dev
I tried installing tidyverse again, no dice. It was still having trouble with xml2 and rvest. I installed xml2 in terminal with.
sudo apt-get install libxml2-dev
After that, rvest installed using Rstudio and tidyverse installed successfully.
These instructions work with both R 4.1.1 and R 3.4.4
It would seem that the R version here is quite old, version 3.6. A bunch of things that are tidyverse related broke around the switch from 3.* to 4.*.
If you follow a procedure like this, it should get you started on the right path with the proper R version and the rest will likely fall into place.
https://linuxize.com/post/how-to-install-r-on-ubuntu-20-04/
Occasionally, on linux machines, you will have packages that fail to install because of system level dependencies that are missing. Those messages are usually informative; they will tell you what you need and the command for acquiring it.

ERROR: compilation failed for package ‘xml2’

I am installing "rvest" and "xml2" packages in Ubuntu 16.04. But on multiple times i am getting the error as below
/usr/lib/R/etc/Makeconf:143: recipe for target 'connection.o' failed
make: *** [connection.o] Error 1
ERROR: compilation failed for package ‘xml2’
* removing ‘/home/prdmcl/R/x86_64-pc-linux-gnu-library/3.2/xml2’
Warning in install.packages :
installation of package ‘xml2’ had non-zero exit status
I checked multiple sources and did this also
sudo apt-get install libcurl4-openssl-dev libssl-dev
sudo apt-get install libxml2-dev
But failed to install.
Seems to be a specific problem with your system(mainly with C++), not with the package.
I had the same problem, and I used this workaround on R command line :
withr::with_makevars(c(CXX = "g++ -std=c++11"),install.packages("xml2", verbose = TRUE))
This will install xml2. After that, you can install rvest package

problem installing ComplexHeatmap. ERROR: compilation failed for package ‘cluster’

i am installing an R package called complex heatmaps (https://jokergoo.github.io/ComplexHeatmap-reference/book/). I get this error. So far i just identified it might be do to this package : https://packages.debian.org/buster/r-cran-cluster but i am not sure what to do at all. Thats why i am writing you.
Thanks a lot for your help
/usr/bin/ld: cannot find -lgfortran
collect2: error: ld returned 1 exit status
/usr/share/R/share/make/shlib.mk:6: recipe for target 'cluster.so' failed
make: *** [cluster.so] Error 1
ERROR: compilation failed for package ‘cluster’
* removing ‘/home/luca/R/x86_64-pc-linux-gnu-library/3.6/cluster’
Error: Failed to install 'ComplexHeatmap' from GitHub:
(converted from warning) installation of package ‘cluster’ had non-zero exit status
The error message indicates that you are missing libfortran.so. You might even miss more tools necessary for installing R packages from source. How to install this depends on the Linux distribution you are using. For Debian, which you mention in the question, this would be
sudo apt install r-base-dev
If you want to speed up package installation, you can also use the binary packages available in Debian, i.e.
sudo apt install r-cran-cluster

installation of package ‘devtools’ had non-zero exit status on Ubuntu

I'm trying to install devtools in a PowerPC with a R version 3.1.1 but failed at the end because the curl library:
...
** testing if installed package can be loaded Error in dyn.load(file, DLLpath = DLLpath, ...) : unable to load shared object '/path
to/R/powerpc-unknown-linux-gnu-library/3.1/curl/libs/curl.so': /path
to/R/powerpc-unknown-linux-gnu-library/3.1/curl/libs/curl.so:
undefined symbol: BSWAP_32 Error: loading failed Execution halted
ERROR: loading failed
* removing ‘/path to/R/powerpc-unknown-linux-gnu-library/3.1/curl’ ERROR: dependency ‘curl’ is not available for package ‘httr’
* removing ‘/path to/R/powerpc-unknown-linux-gnu-library/3.1/httr’ ERROR: dependency ‘curl’ is not available for package ‘rversions’
* removing ‘/path to/R/powerpc-unknown-linux-gnu-library/3.1/rversions’ ERROR:
dependencies ‘httr’, ‘rversions’ are not available for package
‘devtools’
* removing ‘/path to/R/powerpc-unknown-linux-gnu-library/3.1/devtools’
The downloaded source packages are in
‘/tmp/RtmpD0yE63/downloaded_packages’ Warning messages: 1: In
install.packages("devtools") : installation of package ‘curl’ had
non-zero exit status 2: In install.packages("devtools") :
installation of package ‘httr’ had non-zero exit status 3: In
install.packages("devtools") : installation of package ‘rversions’
had non-zero exit status 4: In install.packages("devtools") :
installation of package ‘devtools’ had non-zero exit status
I've already installed libcurl4-gnutls-dev and libcurl4-openssl-dev and the libcurl version is 7.38.0.
Does anyone know a fix to this? Thanks ;)
The same problem happened to me when I was trying to install "devtools" package on a new machine with Ubuntu 16.04 system.
I tried many answers including the adopted one above, but I still couldn't solve the problem until I noticed another warning information "(as ‘lib’ is unspecified)". Then I realized that I was running R as a normal user while the R base is installed by root. It means the package "devtools" couldn't be installed into the default R library folder and possibly couldn't use some dependent packages. Then the solution became very easy: run R as root user and then install "devtools".
Following the instructions of Dean Attali (https://www.digitalocean.com/community/tutorials/how-to-set-up-r-on-ubuntu-14-04), I summarize the steps below. Just run them in a terminal.
$ sudo apt-get -y install libcurl4-gnutls-dev libxml2-dev libssl-dev
$ sudo su
$ R
> install.packages('devtools', repos='http://cran.rstudio.com/')
That's it. Since the package is installed by root, it can be used by all users of the system.
For Curl use:
apt-get -y build-dep libcurl4-gnutls-dev
apt-get -y install libcurl4-gnutls-dev
And you should update the R version to R-3.1.2
wget http://cran.r-project.org/src/base/R-3/R-3.1.2.tar.gz
I m using Ubuntu 16.04 and this is how I solved this issue:
aptitude install libssl-dev
then aptitude packg manage will allow you to choose the right version which is required for installation of devtools.
Repeat the same for
aptitude libcurl4-gnutls-dev
aptitude libxml2-dev
Finally, install this libgit2 lib
devtools::install_github('ropensci/git2r')
devtools::load_all()
R CMD INSTALL git2r
I could not solve it with apt-get packg manager. Thats all :) !
This error was happening when I was using 3.0.2. I updated the R, now It is fine. I also spent the one day to find the solution. I tried the all the solution. But, no effect. I updated the R using this solution. Now, devtools package is working.
Fedora 34
What did it for me was:
sudo dnf groupinstall "Development tools"
Not sure about that, but also:
sudo dnf install freetype-devel libpng-devel libtiff-devel libjpeg-turbo-devel
Don't know, don't care, but it worked!

Error installing BigVis package in RStudio Version 3.0.2

When I run the code to install BigVis package from GitHub as follows,
devtools::install_github("bigvis")
I get the following output:
Installing github repo bigvis/master from hadley
Downloading master.zip from https://github.com/hadley/bigvis/archive/master.zip
Installing package from /var/folders/dl/hhhtf5f52hz7qrw93wfyk_6h0000gn/T//RtmpgkDD2j/master.zip
arguments 'minimized' and 'invisible' are for Windows only
Installing bigvis
'/Library/Frameworks/R.framework/Resources/bin/R' \
--vanilla CMD INSTALL \
'/private/var/folders/dl/hhhtf5f52hz7qrw93wfyk_6h0000gn/T/RtmpgkDD2j/devtools259f1fe8bc61/bigvis-master' \
--library='/Library/Frameworks/R.framework/Versions/3.0/Resources/library' \
--install-tests
* installing *source* package 'bigvis' ...
** libs
sh: make: command not found
ERROR: compilation failed for package 'bigvis'
* removing '/Library/Frameworks/R.framework/Versions/3.0/Resources/library/bigvis'
Error: Command failed (1)
DO YOU HAVE ANY IDEA HOW I MAY FIX IT? THANKS
The error message sh: make: command not found tells you that the program sh could not find the program make. So my crystal ball tells me you might need to install GNU make. But I know nothing about RStudio nor BigVis.

Resources