Install R packages on Ubuntu error - r

I have R and Rstudio installed on an Ubuntu server (14), when I tried to install packages, I get these errors:
>install.packages("nnet")
Installing package into ‘/home/zhge/R/x86_64-pc-linux-gnu-library/3.0’
(as ‘lib’ is unspecified)
--2015-09-08 02:43:31-- https://cran.rstudio.com/src/contrib/nnet_7.3-11.tar.gz Resolving
cran.rstudio.com (cran.rstudio.com)... 54.230.140.42 Connecting to
cran.rstudio.com (cran.rstudio.com)|54.230.140.42|:443... connected.
HTTP request sent, awaiting response... 200 OK Length: 28455 (28K)
[application/x-gzip] Saving to:
‘/tmp/RtmpBT7yHE/downloaded_packages/nnet_7.3-11.tar.gz’
0K .......... .......... ....... 100% 1.20M=0.02s
2015-09-08 02:43:31 (1.20 MB/s) -
‘/tmp/RtmpBT7yHE/downloaded_packages/nnet_7.3-11.tar.gz’ saved
[28455/28455]
/usr/lib/R/bin/R: line 140: /usr/lib/R/etc/ldpaths: Permission denied
/usr/lib/R/bin/R: line 236: /usr/lib/R/etc/ldpaths: Permission denied
Error in file(con, "r") : cannot open the connection Calls:
<Anonymous> -> sub -> grep -> readLines -> file In addition: Warning
message: In file(con, "r") : cannot open file
'/usr/lib/R/etc/Makeconf': Permission denied Warning in
install.packages : installation of package ‘nnet’ had non-zero exit
status
The downloaded source packages are in
‘/tmp/RtmpBT7yHE/downloaded_packages’
UPDATE:
It was just permission issue, all i needed is just:
$ sudo chmod -R 0777 /usr/lib/R/etc/ldpaths
and for the other directories: /usr/lib/R/etc/Makeconf and /usr/lib/R/bin/. I never had this issue before, so it didn't come to me as the problem immediately.

Related

Install R package 'rgdal' and its external dependencies offline on windows

My work laptop has no internet access and I am trying to download the package rgdal.
I have downloaded rgdal_1.4-8.tar.gz, gdal-3.0.4.tar.gz and proj-6.3.2.tar.gz. I tried intalling them via source separately using:
install.packages('.../...tar.gz', type='source', repos=NULL)
but it did not work. Here are the error messages
ERROR: cannot extract package from 'D:/Users/sn/Documents/R source packages/gdal-3.0.4.tar.gz'
Warning in install.packages :
installation of package ‘D:/Users/sn/Documents/R source packages/gdal-3.0.4.tar.gz’ had non-zero exit status
ERROR: cannot extract package from 'D:/Users/sn/Documents/R source packages/proj-6.3.2.tar.gz'
Warning in install.packages :
installation of package ‘D:/Users/sn/Documents/R source packages/proj-6.3.2.tar.gz’ had non-zero exit status
Error in download.file(sprintf("https://github.com/rwinlib/gdal2/archive/v%s.zip", :
cannot open URL 'https://github.com/rwinlib/gdal2/archive/v2.2.3.zip'
In addition: Warning message:
In download.file(sprintf("https://github.com/rwinlib/gdal2/archive/v%s.zip", :
InternetOpenUrl failed: 'A connection with the server could not be established'
Execution halted
make: *** [Makevars.win:27: winlibs] Error 1
ERROR: compilation failed for package 'rgdal'
* removing 'D:/Users/sn/Documents/R/win-library/3.6/rgdal'
Warning in install.packages :
installation of package ‘D:/Users/sn/Documents/R source packages/rgdal_1.4-8.tar.gz’ had non-zero exit status

Installing XLConnect package

I was wanting to install XLConnect package so that i could save my databses created from RSQLite in different formats. But when i do
install.packages("XLConnect")
it seems to give error
checking whether Java run-time works... ./configure: line 3747: /usr/lib/jvm/default-java/bin/java: No such file or directory
no
configure: error: Java interpreter '/usr/lib/jvm/default-java/bin/java' does not work
ERROR: configuration failed for package ‘rJava’
* removing ‘/home/mrshekar/R/x86_64-pc-linux-gnu-library/3.4/rJava’
Warning in install.packages :
installation of package ‘rJava’ had non-zero exit status
ERROR: dependency ‘rJava’ is not available for package ‘XLConnectJars’
* removing ‘/home/mrshekar/R/x86_64-pc-linux-gnu-library/3.4/XLConnectJars’
Warning in install.packages :
installation of package ‘XLConnectJars’ had non-zero exit status
ERROR: dependencies ‘XLConnectJars’, ‘rJava’ are not available for package ‘XLConnect’
* removing ‘/home/mrshekar/R/x86_64-pc-linux-gnu-library/3.4/XLConnect’
Warning in install.packages :
installation of package ‘XLConnect’ had non-zero exit status
Now i read on R: rJava package install failing about the
export JAVA_HOME=/usr/lib/jvm/java-6-sun/jre
export PATH=$PATH:$JAVA_HOME/bin
but still the problem seeems to persist. Also if you look at the solution on Error of java path on loading rJava package
sudo R CMD javareconf
It gives the error
*** JAVA_HOME is not a valid path, ignoring
*** Cannot find any Java interpreter
*** Please make sure 'java' is on your PATH or set JAVA_HOME correspondingly
Also for the install JDK answer
apt-get install r-cran-rjava
I get the permission denied error even if i do it on vm-virtual box it gives me permission denied for the ubuntu 18.04 version i have installed and made myself the admin.
E: Could not open lock file /var/lib/dpkg/lock - open (13: Permission denied)
E: Unable to lock the administration directory (/var/lib/dpkg/), are you root?
What should i do? Please help.

Failure to install `mclust` package in R in Windows 10

When I want to install the package mclust, I get the following error:
> install.packages("mclust")
Installing package into ‘C:/Users/hp1/Documents/R/win-library/3.2’
(as ‘lib’ is unspecified)
There is a binary version available but the source version is
later:
binary source needs_compilation
mclust 5.2.3 5.3 TRUE
Do you want to install from sources the package which needs compilation?
y/n: y
installing the source package ‘mclust’
trying URL 'https://cran.rstudio.com/src/contrib/mclust_5.3.tar.gz'
Content type 'application/x-gzip' length 2792962 bytes (2.7 MB)
downloaded 2.7 MB
* installing *source* package 'mclust' ...
** package 'mclust' successfully unpacked and MD5 sums checked
** libs
*** arch - i386
gcc -m32 -I"C:/PROGRA~1/R/R-32~1.3/include" -DNDEBUG -I"d:/RCompile/r-compiling/local/local323/include" -O3 -Wall -std=gnu99 -mtune=core2 -c init.c -o init.o
gfortran -m32 -O3 -mtune=core2 -c mclust.f -o mclust.o
make: gfortran: Command not found
C:/PROGRA~1/R/R-32~1.3/etc/i386/Makeconf:206: recipe for target 'mclust.o' failed
make: *** [mclust.o] Error 127
Warning: running command 'make -f "Makevars" -f "C:/PROGRA~1/R/R-32~1.3/etc/i386/Makeconf" -f "C:/PROGRA~1/R/R-32~1.3/share/make/winshlib.mk" SHLIB="mclust.dll" SHLIB_LIBADD='$(FLIBS)' OBJECTS="init.o mclust.o mclustaddson.o"' had status 2
ERROR: compilation failed for package 'mclust'
* removing 'C:/Users/hp1/Documents/R/win-library/3.2/mclust'
Warning in install.packages :
running command '"C:/PROGRA~1/R/R-32~1.3/bin/x64/R" CMD INSTALL -l "C:\Users\hp1\Documents\R\win-library\3.2" C:\Users\hp1\AppData\Local\Temp\RtmpiAzB7h/downloaded_packages/mclust_5.3.tar.gz' had status 1
Warning in install.packages :
installation of package ‘mclust’ had non-zero exit status
The downloaded source packages are in
‘C:\Users\hp1\AppData\Local\Temp\RtmpiAzB7h\downloaded_packages’
When digging for solutions on how to fix it, I came across this where the OP says in a comment that the issue was arising due to missing llpack and lblas libraries, which they fixed by installing lapackdev and blasdev packages. But when I try to install these packages, I get error. I checked all my 12 repositories and tried again, but same result.
> install.packages("lapackdev")
Installing package into ‘C:/Users/hp1/Documents/R/win-library/3.2’
(as ‘lib’ is unspecified)
Warning in install.packages :
package ‘lapackdev’ is not available (for R version 3.2.3)
> setRepositories(graphics = getOption("menu.graphics"),
+ ind = NULL, addURLs = character())
--- Please select repositories for use in this session ---
1: + CRAN 2: BioC software
3: BioC annotation 4: BioC experiment
5: BioC extra 6: + CRAN (extras)
7: Omegahat 8: R-Forge
9: rforge.net 10: CRAN (extras, https)
11: R-Forge [https] 12: rforge.net [https]
Enter one or more numbers separated by spaces, or an empty line to cancel
1: 1 2 3 4 5 6 7 8 9 10 11 12
> install.packages("lapackdev")
Warning in install.packages :
cannot open URL 'http://www.omegahat.org/R/src/contrib/PACKAGES.gz': HTTP status was '404 Not Found'
Warning in install.packages :
cannot open URL 'http://www.omegahat.org/R/src/contrib/PACKAGES': HTTP status was '404 Not Found'
Warning in install.packages :
unable to access index for repository http://www.omegahat.org/R/src/contrib:
cannot open URL 'http://www.omegahat.org/R/src/contrib/PACKAGES'
Warning in install.packages :
cannot open URL 'https://R-Forge.R-project.org/src/contrib/PACKAGES.gz': HTTP status was '400 Bad Request'
Warning in install.packages :
cannot open URL 'https://R-Forge.R-project.org/src/contrib/PACKAGES': HTTP status was '400 Bad Request'
Warning in install.packages :
unable to access index for repository https://R-Forge.R-project.org/src/contrib:
cannot open URL 'https://R-Forge.R-project.org/src/contrib/PACKAGES'
Installing package into ‘C:/Users/hp1/Documents/R/win-library/3.2’
(as ‘lib’ is unspecified)
Warning in install.packages :
cannot open URL 'http://www.omegahat.org/R/src/contrib/PACKAGES.gz': HTTP status was '404 Not Found'
Warning in install.packages :
cannot open URL 'http://www.omegahat.org/R/src/contrib/PACKAGES': HTTP status was '404 Not Found'
Warning in install.packages :
unable to access index for repository http://www.omegahat.org/R/src/contrib:
cannot open URL 'http://www.omegahat.org/R/src/contrib/PACKAGES'
Warning in install.packages :
cannot open URL 'https://R-Forge.R-project.org/src/contrib/PACKAGES.gz': HTTP status was '400 Bad Request'
Warning in install.packages :
cannot open URL 'https://R-Forge.R-project.org/src/contrib/PACKAGES': HTTP status was '400 Bad Request'
Warning in install.packages :
unable to access index for repository https://R-Forge.R-project.org/src/contrib:
cannot open URL 'https://R-Forge.R-project.org/src/contrib/PACKAGES'
Warning in install.packages :
package ‘lapackdev’ is not available (for R version 3.2.3)
Warning in install.packages :
cannot open URL 'http://www.omegahat.org/R/bin/windows/contrib/3.2/PACKAGES.gz': HTTP status was '404 Not Found'
Warning in install.packages :
cannot open URL 'http://www.omegahat.org/R/bin/windows/contrib/3.2/PACKAGES': HTTP status was '404 Not Found'
Warning in install.packages :
unable to access index for repository http://www.omegahat.org/R/bin/windows/contrib/3.2:
cannot open URL 'http://www.omegahat.org/R/bin/windows/contrib/3.2/PACKAGES'
Warning in install.packages :
cannot open URL 'http://www.rforge.net/bin/windows/contrib/3.2/PACKAGES.gz': HTTP status was '404 Not Found'
Warning in install.packages :
cannot open URL 'http://www.rforge.net/bin/windows/contrib/3.2/PACKAGES': HTTP status was '404 Not Found'
Warning in install.packages :
unable to access index for repository http://www.rforge.net/bin/windows/contrib/3.2:
cannot open URL 'http://www.rforge.net/bin/windows/contrib/3.2/PACKAGES'
Warning in install.packages :
cannot open URL 'https://R-Forge.R-project.org/bin/windows/contrib/3.2/PACKAGES.gz': HTTP status was '400 Bad Request'
Warning in install.packages :
cannot open URL 'https://R-Forge.R-project.org/bin/windows/contrib/3.2/PACKAGES': HTTP status was '400 Bad Request'
Warning in install.packages :
unable to access index for repository https://R-Forge.R-project.org/bin/windows/contrib/3.2:
cannot open URL 'https://R-Forge.R-project.org/bin/windows/contrib/3.2/PACKAGES'
Warning in install.packages :
cannot open URL 'https://www.rforge.net/bin/windows/contrib/3.2/PACKAGES.gz': HTTP status was '404 Not Found'
Warning in install.packages :
cannot open URL 'https://www.rforge.net/bin/windows/contrib/3.2/PACKAGES': HTTP status was '404 Not Found'
Warning in install.packages :
unable to access index for repository https://www.rforge.net/bin/windows/contrib/3.2:
cannot open URL 'https://www.rforge.net/bin/windows/contrib/3.2/PACKAGES'
Same with blasdev:
> install.packages("blasdev")
Warning in install.packages :
cannot open URL 'http://www.omegahat.org/R/src/contrib/PACKAGES.gz': HTTP status was '404 Not Found'
Warning in install.packages :
cannot open URL 'http://www.omegahat.org/R/src/contrib/PACKAGES': HTTP status was '404 Not Found'
Warning in install.packages :
unable to access index for repository http://www.omegahat.org/R/src/contrib:
cannot open URL 'http://www.omegahat.org/R/src/contrib/PACKAGES'
Warning in install.packages :
cannot open URL 'https://R-Forge.R-project.org/src/contrib/PACKAGES.gz': HTTP status was '400 Bad Request'
Warning in install.packages :
cannot open URL 'https://R-Forge.R-project.org/src/contrib/PACKAGES': HTTP status was '400 Bad Request'
Warning in install.packages :
unable to access index for repository https://R-Forge.R-project.org/src/contrib:
cannot open URL 'https://R-Forge.R-project.org/src/contrib/PACKAGES'
Installing package into ‘C:/Users/hp1/Documents/R/win-library/3.2’
(as ‘lib’ is unspecified)
Warning in install.packages :
cannot open URL 'http://www.omegahat.org/R/src/contrib/PACKAGES.gz': HTTP status was '404 Not Found'
Warning in install.packages :
cannot open URL 'http://www.omegahat.org/R/src/contrib/PACKAGES': HTTP status was '404 Not Found'
Warning in install.packages :
unable to access index for repository http://www.omegahat.org/R/src/contrib:
cannot open URL 'http://www.omegahat.org/R/src/contrib/PACKAGES'
Warning in install.packages :
cannot open URL 'https://R-Forge.R-project.org/src/contrib/PACKAGES.gz': HTTP status was '400 Bad Request'
Warning in install.packages :
cannot open URL 'https://R-Forge.R-project.org/src/contrib/PACKAGES': HTTP status was '400 Bad Request'
Warning in install.packages :
unable to access index for repository https://R-Forge.R-project.org/src/contrib:
cannot open URL 'https://R-Forge.R-project.org/src/contrib/PACKAGES'
Warning in install.packages :
package ‘blasdev’ is not available (for R version 3.2.3)
Warning in install.packages :
cannot open URL 'http://www.omegahat.org/R/bin/windows/contrib/3.2/PACKAGES.gz': HTTP status was '404 Not Found'
Warning in install.packages :
cannot open URL 'http://www.omegahat.org/R/bin/windows/contrib/3.2/PACKAGES': HTTP status was '404 Not Found'
Warning in install.packages :
unable to access index for repository http://www.omegahat.org/R/bin/windows/contrib/3.2:
cannot open URL 'http://www.omegahat.org/R/bin/windows/contrib/3.2/PACKAGES'
Warning in install.packages :
cannot open URL 'http://www.rforge.net/bin/windows/contrib/3.2/PACKAGES.gz': HTTP status was '404 Not Found'
Warning in install.packages :
cannot open URL 'http://www.rforge.net/bin/windows/contrib/3.2/PACKAGES': HTTP status was '404 Not Found'
Warning in install.packages :
unable to access index for repository http://www.rforge.net/bin/windows/contrib/3.2:
cannot open URL 'http://www.rforge.net/bin/windows/contrib/3.2/PACKAGES'
Warning in install.packages :
cannot open URL 'https://R-Forge.R-project.org/bin/windows/contrib/3.2/PACKAGES.gz': HTTP status was '400 Bad Request'
Warning in install.packages :
cannot open URL 'https://R-Forge.R-project.org/bin/windows/contrib/3.2/PACKAGES': HTTP status was '400 Bad Request'
Warning in install.packages :
unable to access index for repository https://R-Forge.R-project.org/bin/windows/contrib/3.2:
cannot open URL 'https://R-Forge.R-project.org/bin/windows/contrib/3.2/PACKAGES'
Warning in install.packages :
cannot open URL 'https://www.rforge.net/bin/windows/contrib/3.2/PACKAGES.gz': HTTP status was '404 Not Found'
Warning in install.packages :
cannot open URL 'https://www.rforge.net/bin/windows/contrib/3.2/PACKAGES': HTTP status was '404 Not Found'
Warning in install.packages :
unable to access index for repository https://www.rforge.net/bin/windows/contrib/3.2:
cannot open URL 'https://www.rforge.net/bin/windows/contrib/3.2/PACKAGES'
What is going on and how do I get mclust to install?
I am answering my own question as the following solved the issue (i.e., mclust was installed successfully) without needing to install the 2 packages I mention in the question. So, this might help someone facing difficulty install mclust.
I updated R version from 3.25 to 3.4, and R studio version from 0.9 to the latest (1.0.143 at the time of writing this answer), and this seems to have solved the issue.

Error installing r package code tools

Im trying to update the codetools package and get the same error is I use update.package() or install.package(), as shown below. Any insight is appreciated:
R> install.packages("codetools", lib = "/usr/lib/R/library")
trying URL 'https://cran.rstudio.com/src/contrib/codetools_0.2-14.tar.gz'
Content type 'application/x-gzip' length 12938 bytes (12 KB)
==================================================
downloaded 12 KB
* installing *source* package ‘codetools’ ...
** package ‘codetools’ successfully unpacked and MD5 sums checked
mv: cannot move ‘/usr/lib/R/library/codetools’ to ‘/usr/lib/R/library/00LOCK-codetools/codetools’: Permission denied
Warning in file.copy(f, instdir, TRUE) : problem copying ./NAMESPACE to /usr/lib/R/library/codetools/NAMESPACE: Permission denied
Warning in file(file, ifelse(append, "a", "w")) : cannot open file '/usr/lib/R/library/codetools/DESCRIPTION': Permission denied
Error in file(file, ifelse(append, "a", "w")) : cannot open the connection
ERROR: installing package DESCRIPTION failed for package ‘codetools’
* removing ‘/usr/lib/R/library/codetools’
Warning in install.packages : installation of package ‘codetools’ had non-zero exit status
The downloaded source packages are in
‘/tmp/RtmpiJWb8L/downloaded_packages’
Updating HTML index of packages in '.Library'
Warning in install.packages : cannot create file '/usr/share/R/doc/html/packages.html', reason 'Permission denied'
Warning in install.packages : cannot update HTML package index
Permission denied sounds like you don't have administrator permission on that system. Try running R as root (or with sudo) and see if it works then.

roxygen2 4.0.1 fails when man/figures is present

In an R package, I have a figure (jpeg) located under man/figures, which is added to a Rd file with,
\if{html}{\figure{supplydemand.jpg}{Supply-demand}}
\if{latex}{\figure{supplydemand}{Supply-demand}}
After updating to roxygen2 4.0.1, I get the error:
==> roxygen2::roxygenize('.', roclets=c('rd', 'collate', 'namespace'))
Error in file(con, "r") : cannot open the connection
Calls: suppressPackageStartupMessages ... <Anonymous> -> first_time -> vapply -> FUN -> readLines -> file
In addition: Warning message:
In file(con, "r") : cannot open file './man/figures': Permission denied
Execution halted
Exited with status 1.
If I remove the code to insert the figure, I still get this error. Only when I remove the subdir man/figures does roxygen2 work OK.
I assume this is a bug in roxygen2 or is there a workaround?

Resources